Example #1
0
int main (int argc, char *argv[])
{
  unsigned long myCounter   = 0 ;
  unsigned long lastCounter = 0 ;

//  fprintf (stderr, "argc=%d\n" , argc);
  if (argc != 2)
  {
    fprintf (stderr, "Usage: %s filename\n", argv[0]);
    return 1 ;
  }

  if (wiringPiSetup () < 0)
  {
    fprintf (stderr, "Unable to setup wiringPi: %s\n", strerror (errno)) ;
    return 1 ;
  }
 
  globalCounter = readFile(argv[1]);

  pinMode (OUT_PIN, OUTPUT) ;
  pinMode (IN_PIN,  INPUT) ;
  pullUpDnControl(IN_PIN,  PUD_UP) ;

  if (wiringPiISR (IN_PIN, INT_EDGE_FALLING, &myInterrupt) < 0)
  {
    fprintf (stderr, "Unable to setup ISR: %s\n", strerror (errno)) ;
    return 1 ;
  }

  if (updateFile(argv[1], 0) != 0 )
  {
    return 1 ;
  }

  for (;;)
  {
    printf ("Waiting ... ") ; fflush (stdout) ;

    while (myCounter == globalCounter)
      delay (100) ;

    if ( lastCounter != 0 ) {
        printf (" Done. counter: %lu: %lu\n",
		globalCounter, myCounter - lastCounter) ;
    }
    lastCounter = myCounter ;
    myCounter   = globalCounter ;
    if ( lastCounter != 0 ) {
        updateFile(argv[1], myCounter);
    }
    digitalWrite (OUT_PIN, globalCounter & 0x1 ) ;
  }

  return 0 ;
}
Example #2
0
    bool insert(const KeyType& key, const filepoint& data){
//        std::cout<<"-----ok in-----"<<std::endl;
        if (rootloc==0){
//            std::cout<<"-----root NULL-----"<<std::endl;
            Tnode<KeyType> root;
            Tnode<KeyType> first;
            root.insert (key,data);
            root.setLeaf (1);
            first = root;
            firstloc = writeToFile (first);
            rootloc = firstloc;
            return true;
        }                                                                          //空树
        Tnode<KeyType> tempnode;
        filepoint temp;
        int keyindex;
        temp = findLeaf (key);
        tempnode = readFromFile (temp);
        keyindex = tempnode.getKeyIndex (key);

        if (keyindex>0 && key == tempnode.getKeyValue (keyindex-1)){
            return false;
        }                                                                       //已经在树中
        if (tempnode.getKeyNum ()<MAXNUM_KEY){   //不分裂插入
//            std::cout<<"notspl::"<<std::endl;
            insert_in_leaf(tempnode,key,data);
            updateFile (temp,tempnode);
        }else{                                  //裂开点
//            std::cout<<"splite::"<<std::endl;
            Tnode<KeyType> newnode;
            insert_in_leaf(tempnode,key,data);
            newnode.setLeaf (1);
            for (int i=0;i<ORDER+1;++i){
                newnode.setKeyValue (i,tempnode.getKeyValue (ORDER-1));
                newnode.setChild (i,tempnode.getChild (ORDER-1));
                tempnode.removeKey (ORDER-1,ORDER-1);
            }
            newnode.setChild (ORDER+1,tempnode.getChild (ORDER-1));
            newnode.setKeyNum (ORDER+1);
            tempnode.setKeyNum (ORDER-1);
            filepoint newp = writeToFile (newnode);
            tempnode.setChild (ORDER-1,newp);
            updateFile (temp,tempnode);
            KeyType newkey = newnode.getKeyValue (0);

            insert_in_parent(temp,newkey,newp);
        }
        return true;
    }
Example #3
0
/*!
    Creates thread
*/
RemoteFileInfoGatherer::RemoteFileInfoGatherer(QObject *parent)
    : AbstractFileInfoGatherer(parent), abort(false)
#ifndef QT_NO_FILESYSTEMWATCHER
    , watcher(0)
#endif
{
    qDebug() << "new RemoteFileInfoGatherer";
#ifndef QT_NO_FILESYSTEMWATCHER
    watcher = new QFileSystemWatcher(this);
    connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(list(QString)));
    connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString)));

#  if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
    const QVariant listener = watcher->property("_q_driveListener");
    if (listener.canConvert<QObject *>()) {
        if (QObject *driveListener = listener.value<QObject *>()) {
            connect(driveListener, SIGNAL(driveAdded()), this, SLOT(driveAdded()));
            connect(driveListener, SIGNAL(driveRemoved()), this, SLOT(driveRemoved()));
        }
    }
#  endif // Q_OS_WIN && !Q_OS_WINRT
#endif
    start(LowPriority);

    emit initialized();
}
Example #4
0
void ZipArchive::closeFile(Stream *stream)
{
   FilterStream *currentStream, *nextStream;

   nextStream = dynamic_cast<FilterStream*>(stream);
   while (nextStream)
   {
      currentStream = nextStream;
      stream = currentStream->getStream();

      currentStream->detachStream();

      nextStream = dynamic_cast<FilterStream*>(stream);

      delete currentStream;
   }

   ZipTempStream *tempStream = dynamic_cast<ZipTempStream *>(stream);
   if(tempStream && (tempStream->getCentralDir()->mInternalFlags & CDFileOpen))
   {
      // [tom, 1/23/2007] This is a temporary file we are writing to
      // so we need to update the relevant information in the header.
      updateFile(tempStream);
   }
}
Example #5
0
void Addons::on_pushButtonUpdate_clicked()
{
    QString urlStr="http://al-anvar.com/addons/addonse-0.4.8.xml";
    QUrl url(urlStr);
    QFileInfo fileInfo(url.path());
    QString fileName = fileInfo.fileName();
    fileName=db->pathUser+"/"+fileName+"-update";
    QFile updateFile(fileName);
    if(updateFile.exists())
         updateFile.remove();
     progressTotal->setVisible(false);
    downlod->downloadFile(urlStr,fileName);
    if(downlod->downloded)
    {
        QFile oldFile(db->pathUser+"/addonse-0.4.8.xml");
        if(oldFile.exists())
             oldFile.remove(db->pathUser+"/addonse-0.4.8.xml");
        if(updateFile.rename(db->pathUser+"/addonse-0.4.8.xml")){
            QMessageBox::information(this,db->trlang("Update Add-ons list"),db->trlang("Add-ons list was updated Successfully"), QMessageBox::Ok);
            treeChargeAddons(treeWidget);
        }else
            QMessageBox::warning(this,db->trlang("Update Add-ons list"),db->trlang("Add-ons list was not updated Successfully"), QMessageBox::Ok);


    }else
         QMessageBox::warning(this,db->trlang("Update Add-ons list"),db->trlang("Add-ons list was not updated Successfully"), QMessageBox::Ok);

}
Example #6
0
bool FormFile::eventFilter(QObject *watched, QEvent *event)
{
    if(watched == ui->lvServer)
    {
        if(event->type() == QEvent::DragEnter)
        {
            QDragEnterEvent* dee = dynamic_cast<QDragEnterEvent*>(event);
            dee->acceptProposedAction();
            return true;
        }
        else if(event->type() == QEvent::Drop)
        {
            QDropEvent* de = dynamic_cast<QDropEvent*>(event);
            QList<QUrl>urls = de->mimeData()->urls();
            if(urls.isEmpty())
            {
                return true;
            }
            QString path = urls.first().toLocalFile();
            //上传文件
            updateFile(path, path.split("/").last());
            return true;
        }
    }

    return QWidget::eventFilter(watched, event);
}
Example #7
0
int FClient::updateFiles(const char *ffile)
{
	FILE *f;
	char fname[PATH_MAX];
	int ret;

	/* open the file */
	f = fopen(ffile,"rt");
	if (!f) {
		printf("failed to open [%s]\n",ffile);
		return -1;
	}

	while (1) {	
		/* read a line */
		ret = fscanf(f,"%s\n",fname);
		if (ret<=0) {
			break;
		}

//		printf("[%s]\n",fname);
		updateFile(fname);
	}

	/* close the file */
	fclose(f);
}
Example #8
0
void CaBundleUpdater::start()
{
    QFile updateFile(m_lastUpdateFileName);
    bool updateNow = false;

    if (updateFile.exists()) {
        if (updateFile.open(QFile::ReadOnly)) {
            QDateTime updateTime = QDateTime::fromString(updateFile.readAll());
            updateNow = updateTime.addDays(5) < QDateTime::currentDateTime();
        }
        else {
            qWarning() << "CaBundleUpdater::start cannot open file for reading" << m_lastUpdateFileName;
        }
    }
    else {
        updateNow = true;
    }

    if (updateNow) {
        m_progress = CheckLastUpdate;

        QUrl url = QUrl::fromEncoded(QString(Qz::WWWADDRESS + QL1S("/certs/bundle_version")).toUtf8());
        m_reply = m_manager->get(QNetworkRequest(url));
        connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished()));
    }
}
Example #9
0
    bool KeywordGenerator::updateTest(const KeywordLoader& loader , const std::string& testFile) const {
        std::stringstream stream;

        stream << testHeader;
        for (auto iter = loader.keyword_begin(); iter != loader.keyword_end(); ++iter) {
            const std::string& keywordName = (*iter).first;
            std::shared_ptr<ParserKeyword> keyword = (*iter).second;
            stream << startTest(keywordName);
            stream << "    std::string jsonFile = \"" << loader.getJsonFile( keywordName) << "\";" << std::endl;
            stream << "    boost::filesystem::path jsonPath( jsonFile );" << std::endl;
            stream << "    Json::JsonObject jsonConfig( jsonPath );" << std::endl;
            stream << "    ParserKeyword jsonKeyword(jsonConfig);" << std::endl;
            stream << "    ParserKeywords::" << keywordName << " inlineKeyword;" << std::endl;
            stream << "    BOOST_CHECK_EQUAL( jsonKeyword, inlineKeyword );" << std::endl;
            stream << "    if (jsonKeyword.hasDimension()) {" <<std::endl;
            stream << "        const auto& parserRecord = jsonKeyword.getRecord(0);" << std::endl;
            stream << "        for (size_t i=0; i < parserRecord.size(); i++){ " << std::endl;
            stream << "            const auto& item = parserRecord.get( i );" << std::endl;
            stream << "            for (size_t j=0; j < item.numDimensions(); j++) {" << std::endl;
            stream << "                const std::string& dimString = item.getDimension(j);" << std::endl;
            stream << "                BOOST_CHECK_NO_THROW( unitSystem.getNewDimension( dimString ));" << std::endl;
            stream << "             }" << std::endl;
            stream << "        }" << std::endl;
            stream << "    }" << std::endl;
            stream << endTest(  );
        }

        return updateFile( stream , testFile );
    }
Example #10
0
bool QgsDelimitedTextFile::open()
{
  if ( ! mFile )
  {
    close();
    mFile = new QFile( mFileName );
    if ( ! mFile->open( QIODevice::ReadOnly ) )
    {
      QgsDebugMsg( "Data file " + mFileName + " could not be opened" );
      delete mFile;
      mFile = 0;
    }
    if ( mFile )
    {
      mStream = new QTextStream( mFile );
      if ( ! mEncoding.isEmpty() )
      {
        QTextCodec *codec =  QTextCodec::codecForName( mEncoding.toAscii() );
        mStream->setCodec( codec );
      }
      if ( mUseWatcher )
      {
        mWatcher = new QFileSystemWatcher();
        mWatcher->addPath( mFileName );
        connect( mWatcher, SIGNAL( fileChanged( QString ) ), this, SLOT( updateFile() ) );
      }
    }
  }
  return mFile != 0;
}
Example #11
0
void dibSHP::getFile()
{
    QString fileName = QFileDialog::getOpenFileName(this, tr("Select file"),
                                fileedit->text(), "Shapefiles *.shp(*.shp)");
    fileedit->setText(fileName);
    updateFile();
}
Example #12
0
KonfUpdate::KonfUpdate()
        : m_textStream(0), m_file(0)
{
    bool updateAll = false;
    m_oldConfig1 = 0;
    m_oldConfig2 = 0;
    m_newConfig = 0;

    m_config = new KConfig("kconf_updaterc");
    KConfigGroup cg(m_config, QString());

    QStringList updateFiles;
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    m_debug = args->isSet("debug");

    m_bUseConfigInfo = false;
    if (args->isSet("check")) {
        m_bUseConfigInfo = true;
        QString file = KStandardDirs::locate("data", "kconf_update/" + args->getOption("check"));
        if (file.isEmpty()) {
            qWarning("File '%s' not found.", args->getOption("check").toLocal8Bit().data());
            log() << "File '" << args->getOption("check") << "' passed on command line not found" << endl;
            return;
        }
        updateFiles.append(file);
    } else if (args->count()) {
        for (int i = 0; i < args->count(); i++) {
            KUrl url = args->url(i);
            if (!url.isLocalFile()) {
                KCmdLineArgs::usageError(i18n("Only local files are supported."));
            }
            updateFiles.append(url.path());
        }
    } else {
        if (cg.readEntry("autoUpdateDisabled", false))
            return;
        updateFiles = findUpdateFiles(true);
        updateAll = true;
    }

    for (QStringList::ConstIterator it = updateFiles.constBegin();
            it != updateFiles.constEnd();
            ++it) {
        updateFile(*it);
    }

    if (updateAll && !cg.readEntry("updateInfoAdded", false)) {
        cg.writeEntry("updateInfoAdded", true);
        updateFiles = findUpdateFiles(false);

        for (QStringList::ConstIterator it = updateFiles.constBegin();
                it != updateFiles.constEnd();
                ++it) {
            checkFile(*it);
        }
        updateFiles.clear();
    }
}
Example #13
0
SCsCodeAnalyzer::SCsCodeAnalyzer(QObject *parent) :
    QObject(parent),
    mIncludesUpdated(false)
{
    mWatcher = new QFileSystemWatcher(this);
    connect(mWatcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString)));

    SCsCodeAnalyzer::init();
}
Example #14
0
CDirectiveHeaderSize::CDirectiveHeaderSize(ArgumentList& args)
{
	if (ConvertExpression(args[0].text,headerSize) == false)
	{
		Logger::printError(Logger::FatalError,L"Invalid header size %s",args[0].text);
	}

	updateFile();
}
Example #15
0
void Level1::birdCheck()
{
    if(birds.isEmpty())
    {
        updateFile();
        lastP *lp = new lastP(QString("you won!!"));
        game->lastPage = lp;
        game->setScene(game->lastPage);
    }
}
Example #16
0
int MultiMC::OnExit()
{
#ifdef WINDOWS
	wxString updaterFileName = "MultiMCUpdate.exe";
#else
	wxString updaterFileName = "MultiMCUpdate";
#endif

	if ((exitAction == EXIT_UPDATE_RESTART || exitAction == EXIT_UPDATE) && 
		wxFileExists(updaterFileName))
	{
		wxFileName updateFile(updaterFileName);
#if LINUX || OSX
			wxExecute("chmod +x " + updateFile.GetFullPath());
			updateFile.MakeAbsolute();
#endif

		wxProcess proc;
		
		wxString updateFilePath = updateFile.GetFullPath();
		wxString thisFilePath = wxStandardPaths::Get().GetExecutablePath();

#if WINDOWS
		wxString launchCmd = wxString::Format("cmd /C %s -u \"%s\"",
			updateFilePath.c_str(), thisFilePath.c_str());
#else
		updateFilePath.Replace(" ", "\\ ");
		thisFilePath.Replace(" ", "\\ ");

		wxString launchCmd = wxString::Format("%s -u:%s",
			updateFilePath.c_str(), thisFilePath.c_str());
#endif

		wxExecute(launchCmd, wxEXEC_ASYNC, &proc);
		proc.Detach();
	}
	else if (exitAction == EXIT_RESTART)
	{
		wxProcess proc;

		// Put together the command that MultiMC launched with.
		wxString launchCmd;
		for (int i = 0; i < argc; i++)
		{
			launchCmd += wxString::Format("%s ", argv[i]);
		}

		wxExecute(launchCmd, wxEXEC_ASYNC, &proc);
		proc.Detach();
	}

	delete settings;
	
	return wxApp::OnExit();
}
NielsenVis::NielsenVis(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::NielsenVis),
    hasDDIData(false)
{
    ui->setupUi(this);

    // Set the initial value of the status area
    ui->statusBar->showMessage("Please add the necessary CSV data files.");

    // Bind unique identifiers to the radio buttons
    ui->sortStyles->setId(ui->Name, ALPHA_SORT);
    ui->sortStyles->setId(ui->Int, INTER_SORT);
    ui->sortStyles->setId(ui->Plan, PLANN_SORT);
    ui->sortStyles->setId(ui->Final, FINAL_SORT);

    /////////////// END RADIO BUTTON STUFF ///////////////

    // Connect all radio buttons to DisplayManager sort orders
    connect(ui->sortStyles, SIGNAL(buttonClicked(int)), &renderer, SLOT(setSortOrder(int)));

    // Connect buttons to local file dialog functions
    connect(ui->Planning, SIGNAL(clicked()), this, SLOT(findPlanningData()));
    connect(ui->Interim, SIGNAL(clicked()), this, SLOT(findCurrentData()));
    connect(ui->FinalCsv, SIGNAL(clicked()), this, SLOT(findFinalData()));

    // Connect the gotDataFile signal to the display manager
    connect(this, SIGNAL(gotDataFile(string,eDataType)), &renderer, SLOT(updateFile(string,eDataType)));

    // Make the combo box populate when the DDIMatrix changes
    connect(&renderer, SIGNAL(ddiDataAdded(list<string>,list<string>)),
            this, SLOT(updateDDI(list<string>,list<string>)));
    connect(ui->PrimKey, SIGNAL(activated(int)), this, SLOT(populateCBox(int)));

    // Set off the event chain when the Add Graph button is clicked
    connect(ui->Add, SIGNAL(clicked()), this, SLOT(prepareChartAdd()));
    connect(this, SIGNAL(chartAddRequest(string,bool)), &renderer, SLOT(chartAdd(string, bool)));
    connect(&renderer, SIGNAL(requestRedraw()), ui->Render, SLOT(chartAdded()));

    // Make the display manager resize its contents when the window resizes
    connect(ui->Render, SIGNAL(resized(int,int)), &renderer, SLOT(renderAreaResized(int,int)));

    // Make the display manager report what files it has
    connect(&renderer, SIGNAL(updateStatusLine(QString)), ui->statusBar, SLOT(showMessage(QString)));

    // Allow display manager to handle mouse actions within the render area
    connect(ui->Render, SIGNAL(mouseMoved(int,int)), &renderer, SLOT(handleMouseMove(int,int)));
    connect(ui->Render, SIGNAL(mouseClicked()), &renderer, SLOT(handleClick()));

    ////////////// END EVENT BINDING //////////////////

    // Set the display manager on the render widget
    ui->Render->setDisplayManager(&renderer);
}
Example #18
0
void FClient::updateAll()
{
	/* request that the file and directory lists be rebuilt */
	printf("updating file list\n");
	requestFileListRebuild();

	/* get local copies of the file and directory lists */
	printf("filelist.txt\n");
	updateFile("filelist.txt");
	printf("dirlist.txt\n");
	updateFile("dirlist.txt");

	/* process each of these files */
	printf("update directory structure\n");
	updateDirectoryStructure("dirlist.txt");

	/* update the files */
	printf("updating the files\n");
	updateFiles("filelist.txt");
}
Example #19
0
void Functionality::redoTask()
{
	if(redoCount.size() != 0)
	{
		if(redoCount[redoCount.size()-1] == 0)
		{
			highPriority = redoHighVector[redoHighVector.size() - 1];
			undoHighVector.push_back(redoHighVector[redoHighVector.size() - 1]);
			redoHighVector.pop_back();
			redoCount.pop_back();
			undoCount.push_back(0);
			cout<<"\nRedo Successful\n";
			Sleep(700);
		}
		else
			if(redoCount[redoCount.size() - 1] == 1)
			{
				normalPriority = redoNormalVector[redoNormalVector.size() - 1];
				undoNormalVector.push_back(redoNormalVector[redoNormalVector.size() - 1]);
				redoNormalVector.pop_back();
				redoCount.pop_back();
				undoCount.push_back(1);
				cout << "\nRedo Successful\n";
				Sleep(700);
			}
			else
				if(redoCount[redoCount.size() - 1] == 2)
				{
					highPriority = redoHighVector[redoHighVector.size() - 1];
					normalPriority = redoNormalVector[redoNormalVector.size() - 1];
					undoHighVector.push_back(redoHighVector[redoHighVector.size() - 1]);
					undoNormalVector.push_back(redoNormalVector[redoNormalVector.size() - 1]);
					redoHighVector.pop_back();
					redoNormalVector.pop_back();
					redoCount.pop_back();
					undoCount.push_back(2);
					cout << "\nRedo Successful\n";
					Sleep(700);
				}
	}
	else
	{
		cout << "\nRedo Unsuccessful\n";
		Sleep(700);
	}

	callSort();
	updateFile();
	notificationFile();
}
Example #20
0
void dsplit(FILE *file, const char *directory) {
	gcry_md_hd_t md;
	FILE *chunk;
	openFile(&md, &chunk);

	uint8_t buffer0[256] = {};
	uint8_t buffer1[256] = {};

	uint8_t *oldBuffer = buffer0;
	uint8_t *newBuffer = buffer1;
	uint16_t hash = 0;
	while (1) {
		int readBytes = fread(newBuffer, 1, 256, file);
		size_t begin = 0;
		for (int i = 0; i < readBytes; i++) {
			uint8_t oldByte = oldBuffer[i];
			uint8_t newByte = newBuffer[i];
			hash = hash * PRIME - UNDO_PRIME * oldByte + newByte;
			if (hash == 0xFFFF) {
				updateFile(md, chunk, newBuffer + begin, i - begin + 1);
				begin = i + 1;
				split(md, chunk, directory);
			}
		}
		updateFile(md, chunk, newBuffer + begin, readBytes - begin);
		if (readBytes != 256) {
			break;
		}
		uint8_t *tmpBuffer = newBuffer;
		newBuffer = oldBuffer;
		oldBuffer = tmpBuffer;
	}
	if (ftell(chunk)) {
		split(md, chunk, directory);
	}
	closeFile(md, chunk);
}
Example #21
0
void Functionality::markAsDone(string eventCode)
{
	int doneCheck = 0;
	vector<EventStorage> eventVector;
	string tempPriority;
	for(int i=1;i<3;i++)
	{
		if( i == 1) eventVector = highPriority;
		else eventVector = normalPriority;
		for (int j=0;j<eventVector.size();j++)
		{
			if(eventVector[j].getCode() == eventCode)
			{
				tempPriority = eventVector[j].getPriority();
				eventVector[j].writeDoneFlag();
				doneCheck = 1;
			}
		}
		if(tempPriority.size()!=0)
		{
			if(tempPriority[0]=='1')
			{
				highPriority = eventVector;
				undoHighVector.push_back(highPriority);
				undoCount.push_back(0);
				tempPriority = "\0";
			}

			else
			{
				normalPriority = eventVector;
				undoNormalVector.push_back(normalPriority);
				undoCount.push_back(1);
				tempPriority = "\0";
			}
		}
	}
	if(doneCheck==0)
		cout<<"\nEvent Code not Found\n";
	else
		cout<<"\nEvent has been marked as done \n";
	Sleep(700);
	redoCount.clear();
	redoHighVector.clear();
	redoNormalVector.clear();
	callSort();
	updateFile();
	notificationFile();
}
void PersonalizePageComponent::buttonClicked(Button* button){
  if (button == backButton) {
    getMainStack().popPage(PageStackComponent::kTransitionTranslateHorizontal);
    resetApplySuccess();
    opt_back.setVisible(false);
    choose_back.setSelectedId(1);
  }
  else if(button == &apply){
    bool ok = updateJSON();
    updateFile(ok);
  }
  else if(button == &add_btn){
    showAddComponents(true);
  }
}
Example #23
0
    bool insert_in_parent(filepoint x,const KeyType &key,filepoint y){
        if (x == rootloc){
//            std::cout<<"insert_in_parent"<<std::endl;
            Tnode<KeyType> newroot;
            newroot.setKeyNum (1);
            newroot.setChild (0,x);
            newroot.setChild (1,y);
            newroot.setKeyValue (0,key);            
            rootloc = writeToFile (newroot);
            return true;
        }else{
            filepoint parent = father[x];
            Tnode<KeyType> parentnode=readFromFile (parent);
            if(parentnode.getKeyNum ()<MAXNUM_KEY){
                int childindex = parentnode.getChildIndex (x);
                parentnode.insert (childindex,childindex+1,key,y);
                updateFile (parent,parentnode);
            }else{
                int kid = parentnode.getKeyIndex (key);
                parentnode.insert (kid,kid+1,key,y);
                Tnode<KeyType> newnode;
                for (int i=0;i<ORDER;++i){
                    newnode.insert (i,i,parentnode.getKeyValue (ORDER),parentnode.getChild (ORDER));
                    parentnode.removeKey (ORDER,ORDER);
                }
                newnode.setChild (ORDER,parentnode.getChild (ORDER));
                filepoint newp = writeToFile (newnode);
                KeyType newkey = parentnode.getKeyValue (ORDER-1);
                parentnode.removeKey (ORDER-1,ORDER);
                updateFile (parent,parentnode);
                insert_in_parent (parent,newkey,newp);
            }
            return true;
        }
        return false;
    }
Example #24
0
ReturnStatus
FileMetaDAO::putFile(const std::string &path, const FileMeta &meta,
                     FileMeta *pMeta, int *pDelta)
{
    assert(pMeta);
    assert(pDelta);

    if (FILE_VERSION_INIT == meta.m_Attr.m_Version) {
    	//ERROR_LOG("createFile, %s", path.c_str());
        return createFile(path, meta, pMeta, pDelta);

    } else {
    	//ERROR_LOG("updateFile, %s", path.c_str());
        return updateFile(path, meta, pMeta, pDelta);
    }
}
Example #25
0
/*!
    Creates thread
*/
QFileInfoGatherer::QFileInfoGatherer(QObject *parent)
    : QThread(parent), abort(false),
#ifndef QT_NO_FILESYSTEMWATCHER
      watcher(0),
#endif
      m_iconProvider(&defaultProvider)
{
    userId = getuid();
    groupId = getgid();
#ifndef QT_NO_FILESYSTEMWATCHER
    watcher = new QFileSystemWatcher(this);
    connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(list(QString)));
    connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString)));
#endif
    start(LowPriority);
}
Example #26
0
/*!
    Creates thread
*/
QFileInfoGatherer::QFileInfoGatherer(QObject *parent)
    : QThread(parent), abort(false),
#ifndef QT_NO_FILESYSTEMWATCHER
      watcher(0),
#endif
#ifdef Q_OS_WIN
      m_resolveSymlinks(true),
#endif
      m_iconProvider(&defaultProvider)
{
#ifndef QT_NO_FILESYSTEMWATCHER
    watcher = new QFileSystemWatcher(this);
    connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(list(QString)));
    connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString)));
#endif
    start(LowPriority);
}
void PersonalizePageComponent::deleteIcon(String name, String shell){
  Array<var>* pages_arr = (json["pages"].getArray());
  const var& pages = ((*pages_arr)[0]);
  Array<var>* items_arr = pages["items"].getArray();
  
  //Searching for the element in the Array
  for(int i = 0; i < items_arr->size(); i++){
    const var& elt = (*items_arr)[i];
    if(elt["name"] == name && elt["shell"] == shell){
      items_arr->remove(i);
      break;
    }
  }
  /*False because we don't want to change the icons in the persoPage
    as it's even not shown */
  updateFile(false);
}
Example #28
0
DlgErrorReport::DlgErrorReport(const QString &xmlWithoutDocument,
                               const QString &xmlWithDocument,
                               QWidget *parent) :
  QDialog (parent),
  m_xmlWithoutDocument (xmlWithoutDocument),
  m_xmlWithDocument (xmlWithDocument)
{
  QVBoxLayout *layout = new QVBoxLayout;
  layout->setSizeConstraint (QLayout::SetFixedSize);
  setLayout (layout);

  QCommonStyle style;
  setModal(true);
  setWindowTitle (tr ("Error Report"));
  setWindowIcon(style.standardIcon (QStyle::SP_MessageBoxCritical));

  QLabel *lblPreview = new QLabel (tr ("An unrecoverable error has occurred. Would you like to send an error report to "
                                       "the Engauge developers?\n\n"
                                       "Adding document information to the error report greatly increases the chances of finding "
                                       "and fixing the problems. However, document information should not be included if your document "
                                       "contains any information that should remain private."));
  lblPreview->setWordWrap(true);
  layout->addWidget (lblPreview);

  m_chkWithDocument = new QCheckBox ("Include document information");
  m_chkWithDocument->setChecked (true);
  updateFile ();
  layout->addWidget (m_chkWithDocument);
  connect (m_chkWithDocument, SIGNAL (stateChanged (int)), this, SLOT (slotDocumentCheckboxChanged (int)));

  QHBoxLayout *layoutButtons = new QHBoxLayout;

  QWidget *panelButtons = new QWidget;
  panelButtons->setLayout (layoutButtons);
  layout->addWidget (panelButtons);

  m_btnSend = new QPushButton(tr ("Send"));
  m_btnSend->setMaximumWidth (MAX_BTN_WIDTH);
  layoutButtons->addWidget (m_btnSend);
  connect (m_btnSend, SIGNAL (released ()), this, SLOT (slotSend()));

  m_btnCancel = new QPushButton(tr ("Cancel"));
  m_btnCancel->setMaximumWidth (MAX_BTN_WIDTH);
  layoutButtons->addWidget (m_btnCancel);
  connect (m_btnCancel, SIGNAL (released ()), this, SLOT (reject ()));
}
Example #29
0
    bool KeywordGenerator::updateSource(const KeywordLoader& loader , const std::string& sourceFile, int blocks ) const {
        std::stringstream newSource;

        const int keywords = loader.size();
        const int blocksize = (keywords / blocks) + 1;

        std::vector< std::stringstream > streams( blocks );
        for( unsigned int i = 0; i < streams.size(); ++i )
            streams[ i ] << sourceHeader << std::endl
                << "void addDefaultKeywords" << i << "(Parser& p);" << std::endl
                << "void addDefaultKeywords" << i << "(Parser& p) {" << std::endl;

        int bi = 0;
        for( auto iter = loader.keyword_begin(); iter != loader.keyword_end(); ++iter ) {
            auto block = bi++ / blocksize;
            streams[ block ] << "p.addKeyword< ParserKeywords::"
                << iter->second->className() << " >();" << std::endl;
        }

        for( auto& stream : streams ) stream << "}}}" << std::endl;

        for( unsigned int i = 0; i < streams.size(); ++i ) {
            auto srcfile = sourceFile;
            updateFile( streams[i], srcfile.insert( srcfile.size() - 4, std::to_string( i ) ) );
        }

        newSource << sourceHeader;
        for (auto iter = loader.keyword_begin(); iter != loader.keyword_end(); ++iter) {
            std::shared_ptr<ParserKeyword> keyword = (*iter).second;
            newSource << keyword->createCode() << std::endl;
        }

        for( auto i = 0; i < blocks; ++i )
            newSource << "void addDefaultKeywords" << i << "(Parser& p);" << std::endl;

        newSource << "}" << std::endl;

        newSource << "void Parser::addDefaultKeywords() {" << std::endl;
        for( auto i = 0; i < blocks; ++i )
            newSource << "Opm::ParserKeywords::addDefaultKeywords" << i << "(*this);" << std::endl;

        newSource << "}}" << std::endl;

        return write_file( newSource, sourceFile, m_verbose, "source" );
    }
Example #30
0
void Functionality::addTask(vector<string> eventDetails)
{
	EventStorage tempEvent;
	int tempCode;
	int tempDigit;
	string tempString;
	ifstream eventCodeGenerate("EventCode.txt");
	eventCodeGenerate>>tempCode;
	eventCodeGenerate.close();
	tempCode += 1;
	ofstream writeCode("EventCode.txt");
	writeCode<<tempCode;
	writeCode.close();
	while(tempCode != 0)
	{
		tempDigit = tempCode%10;
		tempString += char(tempDigit+48);
		tempCode /= 10;		
	}
	eventDetails.pop_back();
	eventDetails.push_back(tempString);
	tempEvent.storeUserInput(eventDetails, 0);
	string eventPriority=tempEvent.getPriority();

	if(eventPriority[0] == '1')
	{
		highPriority.push_back(tempEvent);
		undoHighVector.push_back(highPriority);
		undoCount.push_back(0);
	}
	else
		if(eventPriority[0] == '2')
		{
			normalPriority.push_back(tempEvent);
			undoNormalVector.push_back(normalPriority);
			undoCount.push_back(1);
		}
		redoCount.clear();
		redoHighVector.clear();
		redoNormalVector.clear();
		callSort();
		updateFile();
		notificationFile();
}