예제 #1
0
/** The slot called when user accept some files
  *
  * Several files can be accepted in the same time. The selected files 
  * are moved to the \c upload directory.
  *
  */
void RainbruRPG::Gui::QuarantineList::fileAccept(){
  LOGI("fileAccept called");


   QList<QTreeWidgetItem*> list=tree->selectedItems();
   GlobalURI gu;

   while (!list.isEmpty()){
     QString filename=list.first()->text(0);
     std::string s(filename.toLatin1());
     std::string oldPath=gu.getQuarantineFile(s);
     std::string newPath=gu.getUploadFile(s);
     QString qOldPath(oldPath.c_str());
     QString qNewPath(newPath.c_str());
     QFile f(qOldPath);
     bool success=f.copy(qNewPath);

     if (success){
       bool success2=f.remove();

       if (success2){
	 delete list.takeFirst();
	 emit(filesRemoved(1));
       }
       else{
	 list.takeFirst();
       }
     }
     else{
       list.takeFirst();
     }
   }
}
예제 #2
0
PICComponent::PICComponent( ICNDocument *icnDocument, bool newItem, const char *id )
	: Component( icnDocument, newItem, id ? id : "pic" )
{
	m_name = i18n("PIC Micro");
	
	if ( _def_PICComponent_fileName.isEmpty() )
		_def_PICComponent_fileName = i18n("<Enter location of PIC Program>");
	
	m_bCreatedInitialPackage = false;
	m_bLoadingProgram = false;
	m_pGpsim = 0L;
	
	addButton( "run", QRect(), KIcon( "media-playback-start" ) );
	addButton( "pause", QRect(), KIcon( "media-playback-pause" ) );
	addButton( "reset", QRect(), KIcon( "process-stop" ) );
	addButton( "reload", QRect(), KIcon( "view-refresh" ) );
	
	connect( KTechlab::self(), SIGNAL(recentFileAdded(const KUrl &)), this, SLOT(slotUpdateFileList()) );
	
	connect( ProjectManager::self(),	SIGNAL(projectOpened()),		this, SLOT(slotUpdateFileList()) );
	connect( ProjectManager::self(),	SIGNAL(projectClosed()),		this, SLOT(slotUpdateFileList()) );
	connect( ProjectManager::self(),	SIGNAL(projectCreated()),		this, SLOT(slotUpdateFileList()) );
	connect( ProjectManager::self(),	SIGNAL(subprojectCreated()),	this, SLOT(slotUpdateFileList()) );
	connect( ProjectManager::self(),	SIGNAL(filesAdded()),			this, SLOT(slotUpdateFileList()) );
	connect( ProjectManager::self(),	SIGNAL(filesRemoved()),			this, SLOT(slotUpdateFileList()) );
	
	createProperty( "program", Variant::Type::FileName );
	property("program")->setCaption( i18n("Program") );
	QString filter;
	filter = QString("*.flowcode *.cod *.asm *.basic *.c|%1").arg(i18n("All Supported Files"));
	filter += QString("\n*.flowcode|FlowCode (*.flowcode)");
	filter += QString("\n*.cod|%1 (*.cod)").arg(i18n("Symbol File"));
	filter += QString("\n*.asm|%1 (*.asm)").arg(i18n("Assembly Code"));
	filter += QString("\n*.basic *.microbe|Microbe (*.basic, *.microbe)");
	filter += QString("\n*.c|C (*.c)");
	filter += QString("\n*|%1").arg(i18n("All Files"));
	property("program")->setFilter( filter );
	
	// Used for restoring the pins on file loading before we have had a change
	// to compile the PIC program
	createProperty( "lastPackage", Variant::Type::String );
	property("lastPackage")->setHidden( true );
	
// 	//HACK This is to enable loading with pre-0.3 files (which didn't set a "lastPackage"
// 	// property). This will allow a P16F84 PIC to be initialized (which agrees with pre-0.3
// 	// behaviour), but it will also load it if
	
	// This to allow loading of the PIC component from pre-0.3 files (which didn't set a
	// "lastPackage" property).
	if ( !newItem )
		property("lastPackage")->setValue("P16F84");
	
	slotUpdateFileList();
	slotUpdateBtns();
	
	initPackage( 0 );
}