コード例 #1
0
ファイル: ExportManager.cpp プロジェクト: YunhaiZhou/VaRSoft
/**
 * @brief Exports the portfolios to the archive.
 * The portfolios must have been sets before with addPortfolios.
 */
void ExportManager::exportArchive() {
	QuaZip zip(this->archivePath);
	if(!zip.open(QuaZip::mdCreate)) {
		throw ExportException("Cannot create archive "+this->archivePath+".");
	}

	QuaZipFile archivedFile(&zip);

	// Adds the descriptor file in the archive:
	QByteArray data = writeDescriptor();
	if(!archivedFile.open(QIODevice::WriteOnly, QuaZipNewInfo("portfolios.json"))) {
		throw ExportException("Cannot create descriptor file in archive.");
	}
	archivedFile.write(data);
	archivedFile.close();

	// Adds the reports and assets' files to the archive:
	QDir resourcesFolder(SQLiteManager::getSessionFolder() + QDir::separator() + "Resources");
	addToArchive(resourcesFolder, "Reports", archivedFile);
	addToArchive(resourcesFolder, "Assets", archivedFile);

	zip.close();
	if(zip.getZipError() != 0) {
		throw ExportException("Error while archiving ("+QString::number(zip.getZipError())+").");
	}
}
コード例 #2
0
ファイル: topicfifo.cpp プロジェクト: jnblanchard/ForNacho
/*
 * Thread safe queue operation for deleting an entry to the TopicList using the key (mutex)
 * Lock the TopicList
 * Circular buffer, check that the queue is not empty.
 * A subscriber has read the entry, increase TopicNode readcount and increase the reader index
 * If every subscriber has read the entry then add the node to the archiver.
 * Unlock the TopicList
 */
bool dequeue(TopicList &topicList,  std::string &data, size_t &readerIndex)
{
    bool success = false;
    int lockResult = pthread_mutex_lock(&topicList.mutex);
    assert(lockResult == 0);

    if (readerIndex != topicList.writeIndex) {

        TopicNode &node = topicList.circularBuffer[readerIndex];
        node.readCount++;
        data = node.data;

        readerIndex = succ(readerIndex);
        success = true; // Retrieved the node successfully

        if (node.readCount == topicList.totalSubscribers)
        {
            addToArchive(topicList, &node); // Every subscriber has read the node, archive the node.
            topicList.readIndex = succ(topicList.readIndex);
        }
    }

    pthread_mutex_unlock(&topicList.mutex);
    //fprintf(stderr, "dequeue result: %d\n", success);
    return success;
}
コード例 #3
0
ファイル: kfind.cpp プロジェクト: kthxbyte/KDE1-Linaro
Kfind::Kfind( QWidget *parent, const char *name, const char *searchPath )
    : QWidget( parent, name )
  {
    // init IO buffer
    iBuffer = 0;

    //create tabdialog
    tabDialog = new KfindTabDialog(this,"dialog",searchPath);

    //prepare window for find results
    win = new KfindWindow(this,"window");
    win->hide();  //and hide it firstly    
    winsize=1;

    connect(win ,SIGNAL(resultSelected(bool)),
	    this,SIGNAL(resultSelected(bool)));
    connect(win ,SIGNAL(statusChanged(const char *)),
	    this,SIGNAL(statusChanged(const char *)));
    connect(this,SIGNAL(deleteFile()),
	    win,SLOT(deleteFiles()));
    connect(this,SIGNAL(properties()),
	    win,SLOT(fileProperties()));
    connect(this,SIGNAL(openFolder()),
	    win,SLOT(openFolder()));
    connect(this,SIGNAL(saveResults()),
	    win,SLOT(saveResults()));
    connect(this,SIGNAL(addToArchive()),
	    win,SLOT(addToArchive()));
    connect(this,SIGNAL(open()),
	    win,SLOT(openBinding()));
    connect(parentWidget(),SIGNAL(selectAll()),
	    win,SLOT(selectAll()));
    connect(parentWidget(),SIGNAL(unselectAll()),
	    win,SLOT(unselectAll()));
    connect(parentWidget(),SIGNAL(invertSelection()),
	    win,SLOT(invertSelection()));
    connect(&findProcess,SIGNAL(processExited(KProcess *)),
	    this,SLOT(processResults()));
    connect(&findProcess,SIGNAL(receivedStdout(KProcess *, char *, int)), 
	    this, SLOT(handleStdout(KProcess *, char *, int))) ;
    
    resize(sizeHint());
    //emit haveResults(false); // we're not connectd to anything yet!?
  };
コード例 #4
0
ファイル: topicfifo.cpp プロジェクト: jnblanchard/ForNacho
/* Write all of the remaining nodes from the topicList
 * to the archive. Call this when shutting down the server.
 */
void writeAllToArchive(TopicList &topicList)
{
    int result = pthread_mutex_lock(&topicList.mutex);
    assert(result == 0);

    while (!isEmpty(topicList)) {
        TopicNode &node = topicList.circularBuffer[topicList.readIndex];
        addToArchive(topicList, &node);
        topicList.readIndex = succ(topicList.readIndex);
    }

    flushArchive(topicList);

    pthread_mutex_unlock(&topicList.mutex);
}
コード例 #5
0
ファイル: kfindtop.cpp プロジェクト: kthxbyte/KDE1-Linaro
KfindTop::KfindTop(const char *searchPath) : KTopLevelWidget()
  {
//     setCaption(QString("KFind ")+KFIND_VERSION);

    _toolBar = new KToolBar( this, "_toolBar" );
    _toolBar->setBarPos( KToolBar::Top );      
    _toolBar->show();
    enableToolBar( KToolBar::Show, addToolBar( _toolBar ) );

    _kfind = new Kfind(this,"dialog",searchPath);   
    setView( _kfind, FALSE );
    _kfind->show();

    menuInit();
    toolBarInit();

    setMenu(_mainMenu);
    _mainMenu->show();

    //_mainMenu->enableMoving(false);

    _statusBar = new KStatusBar( this, "_statusBar");
    _statusBar->insertItem("0 file(s) found", 0);
    _statusBar->enable(KStatusBar::Hide);
    setStatusBar( _statusBar );

    connect(_kfind,SIGNAL(haveResults(bool)),
            this,SLOT(enableSaveResults(bool)));
    connect(_kfind,SIGNAL(resultSelected(bool)),
	    this,SLOT(enableMenuItems(bool)));
    connect(this,SIGNAL(deleteFile()),
 	    _kfind,SIGNAL(deleteFile()));
    connect(this,SIGNAL(properties()),
 	    _kfind,SIGNAL(properties()));
    connect(this,SIGNAL(openFolder()),
 	    _kfind,SIGNAL(openFolder()));
    connect(this,SIGNAL(saveResults()),
 	    _kfind,SIGNAL(saveResults()));
    connect(this,SIGNAL(addToArchive()),
 	    _kfind,SIGNAL(addToArchive()));
    connect(this,SIGNAL(open()),
 	    _kfind,SIGNAL(open()));
    connect(_kfind ,SIGNAL(statusChanged(const char *)),
	    this,SLOT(statusChanged(const char *)));
    connect(_kfind ,SIGNAL(enableSearchButton(bool)),
	    this,SLOT(enableSearchButton(bool)));
    connect(_kfind ,SIGNAL(enableStatusBar(bool)),
            this,SLOT(enableStatusBar(bool)));

// No, No, No!!! This is pointless!   (sven)
//    connect(_mainMenu ,SIGNAL(moved(menuPosition)),
//    	    this,SLOT(resizeOnFloating()));
//    connect(_toolBar ,SIGNAL(moved(BarPosition)),
//    	    this,SLOT(resizeOnFloating()));

    //_width=(440>_toolBar->width())?440:_toolBar->width();
    _width=520;
    //_height=(_kfind->sizeHint()).height(); // Unused as far as I can tell

// Fixed and Y-fixed guys:  Please, please, please stop setting fixed size
// on KTW! Fix it on your main view!
//                                     sven

    this->enableStatusBar(false); // _kfile emited before connected (sven)

   }; // and what's this semi-colon for? Grrrr!!!! (sven, too)
コード例 #6
0
ファイル: kfindtop.cpp プロジェクト: kthxbyte/KDE1-Linaro
void KfindTop::toolBarInit()
  {
    KIconLoader *loader = kapp->getIconLoader();
    QPixmap icon;

    icon = loader->loadIcon("search.xpm");
    _toolBar->insertButton( icon, 0, SIGNAL(clicked()),
			    _kfind, SLOT(startSearch()),
			    TRUE, i18n("Start Search"));

    icon = loader->loadIcon("reload.xpm");
    _toolBar->insertButton( icon, 1, SIGNAL(clicked()),
			    _kfind, SLOT(newSearch()),
			    TRUE, i18n("New Search"));

    icon = loader->loadIcon("stop.xpm");
    _toolBar->insertButton( icon, 2, SIGNAL(clicked()),
			    _kfind, SLOT(stopSearch()),
			    FALSE, i18n("Stop Search"));

    _toolBar->insertSeparator();


    icon = loader->loadIcon("openfile.xpm");
    _toolBar->insertButton( icon, 3,SIGNAL(clicked()),
			    _kfind,SIGNAL(open()),
			    FALSE, i18n("Open"));

    icon = loader->loadIcon("archive.xpm");
    _toolBar->insertButton( icon, 4,SIGNAL(clicked()),
			    _kfind,SIGNAL(addToArchive()),
			    FALSE, i18n("Add to archive"));

    icon = loader->loadIcon("delete.xpm");
    _toolBar->insertButton( icon, 5,SIGNAL(clicked()),
			    _kfind,SIGNAL(deleteFile()),
			    FALSE, i18n("Delete"));

    icon = loader->loadIcon("info.xpm");
    _toolBar->insertButton( icon, 6,SIGNAL(clicked()),
			    _kfind,SIGNAL(properties()),
			    FALSE, i18n("Properties"));

    icon = loader->loadIcon("fileopen.xpm");
    _toolBar->insertButton( icon, 7,SIGNAL(clicked()),
			    _kfind,SIGNAL(openFolder()),
			    FALSE, i18n("Open Containing Folder"));

    icon = loader->loadIcon("save.xpm");
    _toolBar->insertButton( icon, 8,SIGNAL(clicked()),
			    _kfind,SIGNAL(saveResults()),
			    FALSE, i18n("Save Search Results"));

    _toolBar->insertSeparator();
    icon = loader->loadIcon("contents.xpm");
    _toolBar->insertButton( icon, 9, SIGNAL( clicked() ),
			  kapp, SLOT( appHelpActivated() ),
			  TRUE, i18n("Help"));

    icon = loader->loadIcon("exit.xpm");
    _toolBar->insertButton( icon, 10, SIGNAL( clicked() ),
                          KApplication::getKApplication(), SLOT( quit() ),  
			  TRUE, i18n("Quit"));
  };
コード例 #7
0
ファイル: kfindtop.cpp プロジェクト: kthxbyte/KDE1-Linaro
void KfindTop::menuInit()
  {
    KStdAccel stdAccel;

    _fileMenu   = new QPopupMenu;
    _editMenu   = new QPopupMenu;
    _optionMenu = new QPopupMenu;
    _helpMenu   = new QPopupMenu;        

    fileStart = _fileMenu->insertItem(i18n("&Start search"), _kfind,
			      SLOT(startSearch()), stdAccel.find());
    fileStop = _fileMenu->insertItem(i18n("S&top search"), _kfind,
			      SLOT(stopSearch()), Key_Escape);    
    _fileMenu->setItemEnabled(fileStop, FALSE);
    _fileMenu->insertSeparator();

    openWithM  = _fileMenu->insertItem(i18n("&Open"),
				       this,SIGNAL(open()), stdAccel.open());
    toArchM    = _fileMenu->insertItem(i18n("&Add to archive"),
				       this,SIGNAL(addToArchive()));
    _fileMenu             ->insertSeparator();
    deleteM    = _fileMenu->insertItem(i18n("&Delete"),
				       this,SIGNAL(deleteFile()));
    propsM     = _fileMenu->insertItem(i18n("&Properties"),
				       this,SIGNAL(properties()));
    _fileMenu             ->insertSeparator();
    openFldrM  = _fileMenu->insertItem(i18n("Open Containing &Folder"),
				       this,SIGNAL(openFolder()));
    _fileMenu             ->insertSeparator();
    saveSearchM= _fileMenu->insertItem(i18n("&Save Search"),
				       this,SIGNAL(saveResults()),stdAccel.save());
    _fileMenu             ->insertSeparator();
    quitM      = _fileMenu->insertItem(i18n("&Quit"),qApp,
				       SLOT(quit()),stdAccel.quit());

    for(int i=openWithM;i>quitM;i--)
       _fileMenu->setItemEnabled(i,FALSE);  
   
    int undo =       _editMenu->insertItem(i18n("&Undo"),
					   this, SIGNAL(undo()), stdAccel.undo() );
    _editMenu                 ->insertSeparator();
    int cut  =       _editMenu->insertItem(i18n("&Cut"),
					   this, SIGNAL(cut()), stdAccel.cut() );
    editCopy =       _editMenu->insertItem(i18n("&Copy"),
					   this, SLOT(copySelection()), stdAccel.copy() );
    _editMenu->insertSeparator();
    editSelectAll = _editMenu->insertItem(i18n("&Select All"),
					   this,SIGNAL(selectAll()) );
    editUnselectAll = _editMenu->insertItem(i18n("Unse&lect All"),
					   this,SIGNAL(unselectAll()) );
    editInvertSelection = _editMenu->insertItem(i18n("&Invert Selection"),
					   this,SIGNAL(invertSelection()) );

    _editMenu->setItemEnabled( undo      , FALSE );
    _editMenu->setItemEnabled( cut       , FALSE );
    _editMenu->setItemEnabled( editCopy  , FALSE );
    _editMenu->setItemEnabled( editSelectAll, FALSE );
    _editMenu->setItemEnabled( editUnselectAll, FALSE );
    _editMenu->setItemEnabled( editInvertSelection, FALSE ); 

    CHECK_PTR( _optionMenu ); 

    _optionMenu->insertItem(i18n("&Preferences ..."),
			    this,SLOT(prefs()));
    //_optionMenu->insertItem("Configure key bindings",this,SIGNAL(keys()));

    QString tmp;
    tmp.sprintf(i18n("KFind %s\nFrontend to find utility\nMiroslav Flídr <*****@*****.**>\n\nSpecial thanks to Stephan Kulow\n<*****@*****.**>"),
                KFIND_VERSION);
    _helpMenu=kapp->getHelpMenu( true, tmp );    

    _mainMenu = new KMenuBar(this, "_mainMenu");
    _mainMenu->insertItem( i18n("&File"), _fileMenu);
    _mainMenu->insertItem( i18n("&Edit"), _editMenu);
    _mainMenu->insertItem( i18n("&Options"), _optionMenu);
    _mainMenu->insertSeparator();
    _mainMenu->insertItem( i18n("&Help"), _helpMenu );
  };