void TableEditor::readRows() { int j = 0; #ifndef QT_NO_TABLE for ( QListBoxItem *i = listRows->firstItem(); i; i = i->next(), ++j ) { if ( i->pixmap() ) table->verticalHeader()->setLabel( j, *i->pixmap(), i->text() ); else table->verticalHeader()->setLabel( j, i->text() ); } #endif }
ListBoxItemDrag::ListBoxItemDrag( ListBoxItemList & items, bool sendPtr, QListBox * parent, const char * name ) : QStoredDrag( "qt/listboxitem", parent, name ) { // ### FIX! QByteArray data( sizeof( Q_INT32 ) + sizeof( QListBoxItem ) * items.count() ); QDataStream stream( data, IO_WriteOnly ); stream << items.count(); stream << (Q_UINT8) sendPtr; // just transfer item pointer; omit data QListBoxItem * i = items.first(); if ( sendPtr ) { while ( i ) { stream << (unsigned long) i; //###FIX: demands sizeof(ulong) >= sizeof(void*) i = items.next(); } } else { while ( i ) { Q_UINT8 b = 0; b = (Q_UINT8) ( i->text() != QString::null ); // does item have text ? stream << b; if ( b ) { stream << i->text(); } b = (Q_UINT8) ( !!i->pixmap() ); // does item have a pixmap ? stream << b; if ( b ) { stream << ( *i->pixmap() ); } stream << (Q_UINT8) i->isSelectable(); i = items.next(); } } setEncodedData( data ); }
void NetworkSettings::SLOT_Disable( bool T ) { QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); QString Msg; if ( ! LBI ) return; NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() ); Log(( "Prepare to %sable\n", (T) ? "en" : "dis" )); Msg = NC->setState( (T) ? Disable : Enable ); if( ! Msg.isEmpty() ) { Msg.insert( 0, "<p>" ); Msg.append( "</p>" ); QMessageBox::warning( 0, tr( "Activating profile" ), Msg ); return; } // reload new state NC->state( true ); updateProfileState( LBI ); }
const KProxyData KManualProxyDlg::data() const { KProxyData data; if (!m_bHasValidData) return data; data.proxyList["http"] = urlFromInput( mDlg->leHttp, mDlg->sbHttp ); if ( mDlg->cbSameProxy->isChecked () ) { data.proxyList["https"] = data.proxyList["http"]; data.proxyList["ftp"] = data.proxyList["http"]; } else { data.proxyList["https"] = urlFromInput( mDlg->leHttps, mDlg->sbHttps ); data.proxyList["ftp"] = urlFromInput( mDlg->leFtp, mDlg->sbFtp ); } if ( mDlg->lbExceptions->count() ) { QListBoxItem* item = mDlg->lbExceptions->firstItem(); for( ; item != 0L; item = item->next() ) data.noProxyFor << item->text(); } data.type = KProtocolManager::ManualProxy; data.useReverseProxy = mDlg->cbReverseProxy->isChecked(); return data; }
void ListBoxCombo::slotLeft2Right() { // Go through all items of the first ListBox for ( unsigned int i = 0; i < lb1->count(); i++ ) { QListBoxItem *item = lb1->item( i ); // if the item is selected... if ( item->selected() ) { // ...and it is a text item... if ( item->pixmap() && !item->text().isEmpty() ) lb2->insertItem( *item->pixmap(), item->text() ); else if ( !item->pixmap() ) lb2->insertItem( item->text() ); else if ( item->text().isEmpty() ) lb2->insertItem( *item->pixmap() ); } } }
void ListBoxEditor::deletePixmap() { if ( preview->currentItem() == -1 ) return; QListBoxItem *i = preview->item( preview->currentItem() ); preview->changeItem( i->text(), preview->currentItem() ); itemDeletePixmap->setEnabled( FALSE ); }
void CustomWidgetEditor::addSignal() { QListBoxItem *i = new QListBoxText( listSignals, "signal()" ); listSignals->setCurrentItem( i ); listSignals->setSelected( i, TRUE ); MetaDataBase::CustomWidget *w = findWidget( boxWidgets->item( boxWidgets->currentItem() ) ); if ( w ) w->lstSignals.append( i->text().latin1() ); }
void ManagerImpl::uninstallSoftware(QThread */*qt*/, void */*data*/) { synce::PROCESS_INFORMATION info = {0, 0, 0, 0 }; QListBoxItem *item = softwareList->item(softwareList->currentItem()); if (Ce::rapiInit(pdaName)) { msg = i18n("Uninstalling software ..."); postManagerImplEvent(&ManagerImpl::beginEvent, 0, noBlock); if (Ce::createProcess(QString("unload.exe").ucs2(), QString(item->text()).ucs2(), NULL, NULL, false, 0, NULL, NULL, NULL, &info)) { postManagerImplEvent(&ManagerImpl::uninstalledEvent, item, noBlock); } else { Ce::rapiUninit(); //kdDebug(2120) << i18n("Failed to start unload.exe, trying to uninstall via Configuration Service Provider ...") << endl; char *configXML; LPWSTR config = NULL; DWORD flags = CONFIG_PROCESS_DOCUMENT; LPWSTR reply = NULL; HRESULT hr; configXML = new char[512]; memset(configXML, 0, 512 * sizeof(char)); strcat(configXML, (char*)"<wap-provisioningdoc>\n\r<characteristic type=\"UnInstall\">\n\r<characteristic type=\""); strcat(configXML, (char*)item->text().latin1()); strcat(configXML, (char*)"\">\n\r<parm name=\"uninstall\" value=\"1\"/>\n\r</characteristic>\n\r</characteristic>\n\r</wap-provisioningdoc>\n\r"); Ce::rapiInit(pdaName); config = synce::wstr_from_current(configXML); hr = Ce::ProcessConfig(config, flags, &reply); if (SUCCEEDED(hr)) { postManagerImplEvent(&ManagerImpl::uninstalledEvent, item, noBlock); } synce::CeRapiFreeBuffer(configXML); synce::wstr_free_string(config); synce::wstr_free_string(reply); } Ce::rapiUninit(); postManagerImplEvent(&ManagerImpl::endEvent, NULL, noBlock); } }
void NetworkSettings::SLOT_Down( void ) { // bring more down QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); int led = -1; QString Msg; if ( ! LBI ) return; NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() ); switch( NC->state() ) { case Disabled : // cannot modify this state case Unknown : // cannot modify this state case Unchecked : // cannot modify this state case Unavailable : // cannot modify this state case Off : // highest DOWN state break; case Available : // -> down led = 0; Log(( "Deactivate interface %s\n", NC->name().latin1() )); Msg = NC->setState( Deactivate ); Down_TB->setEnabled( false ); break; case IsUp : // highest UP state led = 1; Up_TB->setEnabled( true ); Log(( "Bring down interface %s\n", NC->name().latin1() )); Msg = NC->setState( Down, 1 ); if( Msg.isEmpty() ) { // remove 'up' file to make sure unlink ( QString().sprintf( "/tmp/Profile-%d.up", NC->number() ).latin1() );; } break; } if( ! Msg.isEmpty() ) { Msg.insert( 0, "<p>" ); Msg.append( "</p>" ); QMessageBox::warning( 0, tr( "Decrease availability" ), Msg ); return; } updateProfileState( LBI ); // set color of led we should change if( led >= 0 ) { Leds[led]->setColor( blue ); } }
void NetworkSettings::SLOT_Up( void ) { // bring more up QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); QString Msg; int led = -1; if ( ! LBI ) return; NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() ); switch( NC->state() ) { case Disabled : // cannot modify this state case Unknown : // cannot modify this state case Unchecked : // cannot modify this state case Unavailable : // cannot modify this state case IsUp : // highest UP state return; case Off : // -> activate led = 1; Down_TB->setEnabled( true ); Log(( "Activate interface %s\n", NC->name().latin1() )); Msg = NC->setState( Activate ); break; case Available : // -> up led = 2; Log(( "Bring up interface %s\n", NC->name().latin1() )); Msg = NC->setState( Up ); if( Msg.isEmpty() ) { Up_TB->setEnabled( false ); } break; } if( ! Msg.isEmpty() ) { Msg.insert( 0, "<p>" ); Msg.append( "</p>" ); QMessageBox::warning( 0, tr( "Increase availability" ), Msg ); return; } updateProfileState( LBI ); // set color of led we should change if( led > 0 ) { Leds[led]->setColor( blue ); Leds[led]->setOn( true ); } }
ConfigEstateGroup *GroupEditor::currentGroup() { QListBoxItem *item = groups->item(groups->currentItem()); if (!item) return 0; for (ConfigEstateGroupList::Iterator it = mylist.begin(); it != mylist.end(); ++it) if ((*it).name() == item->text()) return &(*it); return 0; }
void ListBoxEditor::moveItemUp() { if ( preview->currentItem() < 1 ) return; QListBoxItem *i = preview->item( preview->currentItem() ); bool hasPix = (bool)i->pixmap(); QPixmap pix; if ( hasPix ) pix = *i->pixmap(); QString txt = i->text(); QListBoxItem *p = i->prev(); if ( p->pixmap() ) preview->changeItem( *p->pixmap(), p->text(), preview->currentItem() ); else preview->changeItem( p->text(), preview->currentItem() ); if ( hasPix ) preview->changeItem( pix, txt, preview->currentItem() - 1 ); else preview->changeItem( txt, preview->currentItem() - 1 ); }
void ossimQtBandSelectorController::rightButtonClicked() const { // Find the selected items and move them over. const int COUNT = theDialog->theAvailableBandsListBox->count(); for (int i = 0; i < COUNT; ++i) { if (theDialog->theAvailableBandsListBox->isSelected(i)) { QListBoxItem* item = theDialog->theAvailableBandsListBox->item(i); QString s = item->text(); theDialog->theSelectedBandsListBox->insertItem(s); } } }
void ListBoxEditor::moveItemDown() { if ( preview->currentItem() == -1 || preview->currentItem() > (int)preview->count() - 2 ) return; QListBoxItem *i = preview->item( preview->currentItem() ); bool hasPix = (bool)i->pixmap(); QPixmap pix; if ( hasPix ) pix = *i->pixmap(); QString txt = i->text(); QListBoxItem *n = i->next(); if ( n->pixmap() ) preview->changeItem( *n->pixmap(), n->text(), preview->currentItem() ); else preview->changeItem( n->text(), preview->currentItem() ); if ( hasPix ) preview->changeItem( pix, txt, preview->currentItem() + 1 ); else preview->changeItem( txt, preview->currentItem() + 1 ); }
ListBoxEditor::ListBoxEditor( QWidget *parent, QWidget *editWidget, FormWindow *fw ) : ListBoxEditorBase( parent, 0, TRUE ), formwindow( fw ) { connect( helpButton, SIGNAL( clicked() ), MainWindow::self, SLOT( showDialogHelp() ) ); listbox = (QListBox*)editWidget; itemText->setText( "" ); itemText->setEnabled( FALSE ); itemPixmap->setText( "" ); itemChoosePixmap->setEnabled( FALSE ); itemDeletePixmap->setEnabled( FALSE ); QListBoxItem *i = 0; for ( i = listbox->firstItem(); i; i = i->next() ) { if ( i->pixmap() ) (void)new QListBoxPixmap( preview, *i->pixmap(), i->text() ); else (void)new QListBoxText( preview, i->text() ); } if ( preview->firstItem() ) preview->setCurrentItem( preview->firstItem() ); }
void NetworkSettings::SLOT_DeleteNode( void ) { QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); if ( ! LBI ) return; if( QMessageBox::warning( 0, tr( "Removing profile" ), tr( "Remove selected profile ?" ), 1, 0 ) == 1 ) { NSResources->removeNetworkSetup( LBI->text() ); delete LBI; NSD.setModified( 1 ); } }
void ossimQtBandSelectorController::downButtonClicked() const { // Find the selected items and move them down. const int COUNT = theDialog->theSelectedBandsListBox->count(); for (int i = (COUNT-2); i >= 0; --i) // Skip the bottom cell... { if (theDialog->theSelectedBandsListBox->isSelected(i)) { QListBoxItem* item = theDialog->theSelectedBandsListBox->item(i); QString s = item->text(); theDialog->theSelectedBandsListBox->removeItem(i); theDialog->theSelectedBandsListBox->insertItem(s, (i+1)); } } }
void ossimQtBandSelectorController::upButtonClicked() const { // Find the selected items and move them up. const int COUNT = theDialog->theSelectedBandsListBox->count(); for (int i = 1; i < COUNT; ++i) // Skip the top cell... { if (theDialog->theSelectedBandsListBox->isSelected(i)) { QListBoxItem* item = theDialog->theSelectedBandsListBox->item(i); QString s = item->text(); theDialog->theSelectedBandsListBox->removeItem(i); theDialog->theSelectedBandsListBox->insertItem(s, (i-1)); } } }
void ListBoxEditor::applyClicked() { QListBoxItem *i = 0; QValueList<PopulateListBoxCommand::Item> items; for ( i = preview->firstItem(); i; i = i->next() ) { PopulateListBoxCommand::Item item; if ( i->pixmap() ) item.pix = *i->pixmap(); item.text = i->text(); items.append( item ); } PopulateListBoxCommand *cmd = new PopulateListBoxCommand( tr( "Edit Items of '%1'" ).arg( listbox->name() ), formwindow, listbox, items ); cmd->execute(); formwindow->commandHistory()->addCommand( cmd ); }
void NetworkSettings::SLOT_RefreshStates( void ) { QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember if( LBI ) { NetworkSetup * NC; NSResources->system().probeInterfaces(); // update current selection only NC = NSResources->findNetworkSetup( LBI->text() ); if( NC ) { State_t OldS = NC->state(); State_t NewS = NC->state(1); if( OldS != NewS ) { updateProfileState( LBI ); } } } /* -> LATER !! bool is; NetworkSetup * NC; for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) { NC = NSResources->findNetworkSetup( Profiles_LB->text(i) ); if( NC ) { State_t OldS = NC->state(); State_t NewS = NC->state(1); if( OldS != NewS ) { is = Profiles_LB->isSelected(i); Profiles_LB->changeItem( NC->statePixmap(NewS), NC->name(), i ); if( is ) { Profiles_LB->setSelected( i, TRUE ); } } } } if( ci >= 0 ) Profiles_LB->setCurrentItem( ci ); */ }
bool KManualProxyDlg::handleDuplicate( const QString& site ) { QListBoxItem* item = mDlg->lbExceptions->firstItem(); while ( item != 0 ) { if ( item->text().findRev( site ) != -1 && item != mDlg->lbExceptions->selectedItem() ) { QString msg = i18n("You entered a duplicate address. " "Please try again."); QString details = i18n("<qt><center><b>%1</b></center> " "is already in the list.</qt>").arg(site); KMessageBox::detailedError( this, msg, details, i18n("Duplicate Entry") ); return true; } item = item->next(); } return false; }
void TKComboBox::paintEvent(QPaintEvent*) { QRect r; if (editable()){ #ifdef __GNUC__ #warning "Left out for now, lacking a style expert (Werner)" #endif //r = QRect( style().comboButtonRect( 0, 0, width(), height() ) ); r = QRect(4, 2, width()-height()-2, height()-4); } else { r = QRect(4, 2, width()-height()-2, height()-4); } int by = 2; int bx = r.x() + r.width(); int bw = width() - bx - 2; int bh = height()-4; QPainter p( this ); const QColorGroup& g = colorGroup(); QRect fr(2,2,width()-4,height()-4); if ( hasFocus()) { p.fillRect( fr, g.brush( QColorGroup::Highlight ) ); } else { p.fillRect( fr, g.brush( QColorGroup::Base ) ); } QRect r1(1,1,width()-1,height()-1); qDrawShadePanel( &p, r1, g, true, 1 ); static const char* arrow_down[] = { "7 7 2 1", "X c Gray0", " c None", "XXXXXXX", "XXXXXXX", " ", "XXXXXXX", " XXXXX ", " XXX ", " X "}; QPixmap pixmap(arrow_down); style().drawControl( QStyle::CE_PushButton, &p, this, QRect( bx, by, bw, bh ), colorGroup() ); style().drawItem( &p, QRect( bx, by, bw, bh), AlignCenter, colorGroup(), isEnabled(), &pixmap, QString::null ); if ( hasFocus()) { style().drawPrimitive( QStyle::PE_FocusRect, &p, fr, g ); } if (!editable()) { p.setClipRect(r); p.setPen( g.text() ); p.setBackgroundColor( g.background() ); if ( listBox()->item(currentItem()) ) { QListBoxItem * item = listBox()->item(currentItem()); const QPixmap *pix = item->pixmap(); QString text = item->text(); int x = r.x(); if ( pix ) { p.drawPixmap( x, r.y() + ( r.height() - pix->height() ) / 2 +1, *pix ); x += pix->width()+3; } if (!text.isEmpty()) p.drawText( x, r.y(), r.width()-x, r.height(), AlignLeft|AlignVCenter|SingleLine, text ); } } p.end(); }
void CDPWizard::formSelected(const QString &thePageNameQString) { QString myQString; QLineEdit *myLineEdit; if (thePageNameQString==tr("Raw data file selection")) { #ifdef QGISDEBUG std::cout << "Opening Raw Data File Selection page" << std::endl; #endif checkInputFilenames(); } if (thePageNameQString==tr("File type and variables")) //we do this after leaving the file selection page { //#ifdef QGISDEBUG std::cout << "Leaving file selection page" << std::endl; //#endif /** @todo Add some checking to make sure each file exists and is readable and valid for its type */ climateDataProcessor->setMeanTempFileName(leMeanTemp->text()); climateDataProcessor->setMinTempFileName(leMinTemp->text()); climateDataProcessor->setMaxTempFileName(leMaxTemp->text()); climateDataProcessor->setDiurnalTempFileName(leDiurnalTemp->text()); climateDataProcessor->setMeanPrecipFileName(leMeanPrecipitation->text()); climateDataProcessor->setFrostDaysFileName(leFrostDays->text()); climateDataProcessor->setTotalSolarRadFileName(leTotalSolarRadiation->text()); //turn off next button until one or more variables have been selected setNextEnabled(currentPage(), false); ///////////////////////////////////////////////////////////////////// // // OK now we need to update the list of available calculations that // can be carried out. // ///////////////////////////////////////////////////////////////////// // // get the input file type // climateDataProcessor->setInputFileType("GDAL Supported Raster"); //Should not need to have the next line here - it slows everythinf down! //climateDataProcessor->makeFileGroups(); //#ifdef QGISDEBUG std::cout << "Getting available calculations list" << std::endl; //#endif climateDataProcessor->makeAvailableCalculationsMap(); // and then update the list box //List the calculations in availableCalculationsMap using an iterator QMap<QString, bool> myAvailableCalculationsMap = climateDataProcessor->getAvailableCalculationsMap(); QMap<QString, bool>::const_iterator myIter; //#ifdef QGISDEBUG std::cout << myAvailableCalculationsMap.size() << " available calculations in list which are:" << std::endl; std::cout << climateDataProcessor->getDescription() << std::endl; //#endif //clear the current entries from the box lstVariablesToCalc->clear(); for (myIter=myAvailableCalculationsMap.begin(); myIter != myAvailableCalculationsMap.end(); myIter++) { if (myIter.data()) { //#ifdef QGISDEBUG std::cout << myIter.key() << QString(": true\n"); //#endif //need to add some logic here to select the inserted item lstVariablesToCalc->insertItem(myIter.key()); } else { #ifdef QGISDEBUG std::cout << myIter->first << QString(": false\n"); #endif //need to add some logic here to select the inserted item lstVariablesToCalc->insertItem(myIter.key()); } } } //end of test for page 3 if (thePageNameQString==tr("Output destination")) //we do this after leaving the file type and variables page { } if (thePageNameQString==tr("Summary of processing to be performed")) //we do this when we arrive at the summary of variables to be calculated { //update the summary of vars to calculate txtVariableSummary->clear(); for ( unsigned int i = 0; i < lstVariablesToCalc->count(); i++ ) { QListBoxItem *item = lstVariablesToCalc->item( i ); // if the item is selected... if ( item->isSelected() ) { // increment the count of selected items txtVariableSummary->append(item->text()); } } //update the output file format summary box leInputFormatSummary->setText("GDAL Supported Raster"); //update the file output path box leOutputPathSummary->setText(leOutputPath->text()); txtInputFileSummary->clear(); txtInputFileSummary->append(leMeanTemp->text()); txtInputFileSummary->append(leMinTemp->text()); txtInputFileSummary->append(leMaxTemp->text()); txtInputFileSummary->append(leDiurnalTemp->text()); txtInputFileSummary->append(leMeanPrecipitation->text()); txtInputFileSummary->append(leMeanPrecipitation->text()); txtInputFileSummary->append(leFrostDays->text()); txtInputFileSummary->append(leTotalSolarRadiation->text()); } //end of test for page 5 if (thePageNameQString==tr("Progress")) //we do this when we start the calculation { qApp->processEvents(); run(); } } //end of formSelected
void CDPWizard::run() { QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); qApp->processEvents(); //mark the start time: startTime.start(); QString myLabelString; myLabelString.sprintf("<p align=\"right\">Time elapsed: %d s</p>", startTime.elapsed()/1000); lblElapsedTime->setText(myLabelString); int myFirstYearInFileInt, myJobStartYearInt, myJobEndYearInt; QString myInputFileTypeString, myOutputFileTypeString, myOutputPathString; QString myQString; // get the ouput file path climateDataProcessor->setOutputFilePathString(leOutputPath->text()+QDir::separator ()); // get the input file type climateDataProcessor->setInputFileType("GDAL Supported Raster"); // get the ouput file type climateDataProcessor->setOutputFileType(cboOutputFormat->currentText()); //! @todo Get rid of the whole files in series paradigm climateDataProcessor->setFilesInSeriesFlag(true); //setup the climate data processor's filereaders /** @todo see what this hardcoding means and remove if possible */ if (!climateDataProcessor->makeFileGroups ()) { std::cerr << "cdpwizards call to make file groups failed!" << std::endl; return; } //add each selected user calculation to the user calculation map // Go through all items of the first ListBox unsigned int myVarsCount=0; for ( unsigned int i = 0; i < lstVariablesToCalc->count(); i++ ) { QListBoxItem *myQListBoxItem = lstVariablesToCalc->item( i ); // if the item is selected... if ( myQListBoxItem->isSelected() ) { climateDataProcessor->addUserCalculation(myQListBoxItem->text().latin1() ); myVarsCount++; } } progressTotalJob->setProgress(0,myVarsCount); //get a summary of the climate dataprocessor class now #ifdef QGISDEBUG std::cout << climateDataProcessor->getDescription() << endl; #endif // //now we let the climatedataprocessor run! // climateDataProcessor->run(); QApplication::restoreOverrideCursor(); setFinishEnabled( step_6, TRUE ); } //end of run()
void kiptablesgenerator::accept() { QString rulesList; rulesList = "#!/bin/sh\n" + i18n("# Generated by KIptablesGenerator\n") + i18n("# Copyright (c) 2004 Fred Emmott <*****@*****.**>\n") + i18n("# See KIptablesGenerator for license information.\n") + i18n("# You probably want to make this a startup script, eg on\n") + i18n("# slackware you probably want to save this as /etc/rc.d/rc.firewall\n")+ "IPTABLES=/usr/sbin/iptables\n"; if (((QButtonGroup*) namedWidgets["incomingYesNo"])->selected()->name() == (QString) "yes") { if ( ((KComboBox*) namedWidgets["incomingPolicy"])->currentItem() == 0) rulesList += "$IPTABLES -P INPUT ACCEPT\n"; else rulesList += "$IPTABLES -P INPUT DROP\n"; KListBox* interfaces = (KListBox*) namedWidgets["iInterfaces"]; for (unsigned int i = 0; i < interfaces->count(); i++) { QListBoxItem* interface = interfaces->item(i); if (! interface->isSelected()) rulesList += QString("$IPTABLES -A INPUT -i %1 -j ACCEPT\n").arg(interface->text()); } KListView* hosts = (KListView*) namedWidgets["hostsList"]; QListViewItem* host = hosts->firstChild(); while (host) { QString accept = host->text(0), ipOrMAC = host->text(1), address = host->text(2), action; accept == i18n("Allow") ? action = "ACCEPT" : action = "DROP"; ipOrMAC == i18n("IP") ? rulesList += QString("$IPTABLES -A INPUT -s %1 -j %2\n").arg(address).arg(action) : rulesList += QString("$IPTABLES -A INPUT -m mac --mac-source %1 -j %2\n").arg(address).arg(action); host = host->nextSibling(); } if (((QCheckBox *) namedWidgets["iCheckLocalSpoof"])->isChecked()) rulesList += "$IPTABLES -A INPUT ! -i lo -d 127.0.0.0/8 -j DROP\n"; if (((QCheckBox *) namedWidgets["iSynFloodProtect"])->isChecked()) { rulesList += "$IPTABLES -N Flood-Scan\n"; rulesList += "$IPTABLES -A INPUT -p tcp -m tcp --syn -j Flood-Scan\n"; rulesList += "$IPTABLES -A Flood-Scan -m limit --limit 1/s --limit-burst 20 -j RETURN\n"; rulesList += "$IPTABLES -A Flood-Scan -j DROP\n"; } if (((QCheckBox *) namedWidgets["iCheckSyn"])->isChecked()) rulesList += "$IPTABLES -A INPUT -p tcp -m tcp ! --syn -m conntrack --ctstate NEW -j DROP\n"; if (((QCheckBox *) namedWidgets["iCheckSynFin"])->isChecked()) rulesList += "$IPTABLES -A INPUT -p tcp -m tcp --tcp-flags SYN,FIN SYN,FIN -j DROP\n"; if ( ((QCheckBox*) namedWidgets["iConntrackAllSame"])->isChecked() ) { if ( ((QCheckBox*) namedWidgets["iConntrackAllEstablished"])->isChecked() ) rulesList += "$IPTABLES -A INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT\n"; if ( ((QCheckBox*) namedWidgets["iConntrackAllRelated"])->isChecked() ) rulesList += "$IPTABLES -A INPUT -m conntrack --ctstate RELATED -j ACCEPT\n"; if ( ((QCheckBox*) namedWidgets["iConntrackAllNew"])->isChecked() ) rulesList += "$IPTABLES -A INPUT -m conntrack --ctstate NEW -j ACCEPT\n"; } else { if ( ((QCheckBox*) namedWidgets["iConntrackTcpEstablished"])->isChecked() ) rulesList += "$IPTABLES -A INPUT -p tcp -m conntrack --ctstate ESTABLISHED -j ACCEPT\n"; if ( ((QCheckBox*) namedWidgets["iConntrackTcpRelated"])->isChecked() ) rulesList += "$IPTABLES -A INPUT -p tcp -m conntrack --ctstate RELATED -j ACCEPT\n"; if ( ((QCheckBox*) namedWidgets["iConntrackTcpNew"])->isChecked() ) rulesList += "$IPTABLES -A INPUT -p tcp -m conntrack --ctstate NEW -j ACCEPT\n"; if ( ((QCheckBox*) namedWidgets["iConntrackUdpEstablished"])->isChecked() ) rulesList += "$IPTABLES -A INPUT -p udp -m conntrack --ctstate ESTABLISHED -j ACCEPT\n"; if ( ((QCheckBox*) namedWidgets["iConntrackUdpRelated"])->isChecked() ) rulesList += "$IPTABLES -A INPUT -p udp -m conntrack --ctstate RELATED -j ACCEPT\n"; if ( ((QCheckBox*) namedWidgets["iConntrackUdpNew"])->isChecked() ) rulesList += "$IPTABLES -A INPUT -p udp -m conntrack --ctstate NEW -j ACCEPT\n"; if ( ((QCheckBox*) namedWidgets["iConntrackICMPEstablished"])->isChecked() ) rulesList += "$IPTABLES -A INPUT -p icmp -m conntrack --ctstate ESTABLISHED -j ACCEPT\n"; if ( ((QCheckBox*) namedWidgets["iConntrackICMPRelated"])->isChecked() ) rulesList += "$IPTABLES -A INPUT -p icmp -m conntrack --ctstate RELATED -j ACCEPT\n"; if ( ((QCheckBox*) namedWidgets["iConntrackICMPNew"])->isChecked() ) rulesList += "$IPTABLES -A INPUT -p icmp -m conntrack --ctstate NEW -j ACCEPT\n"; } KListView* services = (KListView*) namedWidgets["iPorts"]; QListViewItem* service = services->firstChild(); while (service) { // columns: portNumber, protoName, action, portName QString portNumber = service->text(0), protocol = service->text(1), action = service->text(2), portName = service->text(3); action == i18n("Accept") ? action = "ACCEPT" : action = "DROP"; if (protocol == i18n("TCP & UDP") || protocol == i18n("TCP")) rulesList += QString("$IPTABLES -A INPUT -p tcp -m tcp --dport %1 -j %2\n").arg(portNumber).arg(action); if (protocol == i18n("TCP & UDP") || protocol == i18n("UDP")) rulesList += QString("$IPTABLES -A INPUT -p udp -m udp --dport %1 -j %2\n").arg(portNumber).arg(action); if (protocol == i18n("ICMP")) rulesList += QString("$IPTABLES -A INPUT -p icmp -m icmp --icmp-type %1 -j %2\n").arg(portName).arg(action); service = service->nextSibling(); } KListView* forwards = (KListView*) namedWidgets["forwardsList"]; QListViewItem* forward = forwards->firstChild(); while (forward) { QString direction = forward->text(0), localPort = forward->text(1), destination = forward->text(2); direction == i18n("Incoming") ? rulesList += QString("$IPTABLES -t nat -A PREROUTING -p tcp -m tcp --dport %1 -j DNAT --to %2\n").arg(localPort).arg(destination) : rulesList += QString("$IPTABLES -t nat -A OUTPUT -p tcp -m tcp --dport %1 -j DNAT --to %2\n").arg(localPort).arg(destination); forward = forward->nextSibling(); } } this->hide(); rulesDialog = new RulesDialog(this,(char*) 0, &rulesList); rulesDialog->show(); connect(rulesDialog, SIGNAL(closeClicked()), this, SLOT(slotShownRules())); }