Example #1
0
QString Hash::Do(QString password, QString page, bool isCheck)
{
    QStringList pages = settings.value("pages").toStringList();
    if (!isCheck && !page.isEmpty())
    {
        if (!pages.contains(page))
            pages.append(page);

        pages.move(pages.indexOf(page), 0);
        settings.setValue("pages", pages);
        context->setContextProperty("myModel", pages);
    }

    hash.reset();
	hash.addData(password.toUtf8());
	hash.addData(page.toUtf8());
	QString result = hash.result().toBase64(QByteArray::OmitTrailingEquals).replace('+', "").replace('/', "").left(password_length);

    if (!isCheck)
    {
        qApp->clipboard()->setText(result, QClipboard::Clipboard);
        qApp->clipboard()->setText(result, QClipboard::Selection);
    }

    return result;
}
Example #2
0
void GraphicalUriArray::moveItems( int step )
{
  QModelIndexList selected = m_listView->selectionModel()->selectedRows();
  QModelIndexList::iterator it = selected.begin();
  QStringList items = m_model->stringList();
  QList<int> newSelection;

  // move the elements
  for( ; it != selected.end() ; ++it )
  {
      int row = it->row();
      int newRow = row + step;

//      if(  newRow >= 0 && newRow < items.count() )
      items.move( row, newRow );    // move the row
      newSelection.append( newRow );
  }

  m_model->setStringList(items); // set the new items

  // select items that were just moved
  QList<int>::iterator itNewSelect = newSelection.begin();
  for( ; itNewSelect != newSelection.end(); ++ itNewSelect)
    m_listView->selectionModel()->select( m_model->index(*itNewSelect), QItemSelectionModel::Select );

  // update buttons enabled states
  selectionChanged(QItemSelection(), QItemSelection());
}
Example #3
0
void LPMain::updateSnapshots(){
    qDebug() << "Snapshot data Available";
    QStringList dslist = POOLDATA.subsets();
    dslist.sort();
    //Now move the home directories to the top of the list
    int moved = 0;
    for(int i=0; i<dslist.length(); i++){  //make sure it stays in alphabetical order
      if(dslist[i].startsWith("/usr/home/")){
        dslist.move(i,moved);
	moved++; 
	i--; //make sure to not miss any items from moving
      }
    }
    ui->combo_datasets->addItems(dslist);
    int dsin = dslist.indexOf(cds);
    if(dsin >= 0){ ui->combo_datasets->setCurrentIndex(dsin); }
    else if( !dslist.isEmpty() ){ ui->combo_datasets->setCurrentIndex(0); }
    else{ ui->combo_datasets->addItem(tr("No datasets available")); }
    //NOTE: this automatically calls the "updateDataset()" function
    
    //Now update the snapshot removal menu list
    //QStringList snapComments;
    QStringList snaps = POOLDATA.allSnapshots(); //LPBackend::listLPSnapshots(ui->combo_pools->currentText(), snapComments);
    ui->menuDelete_Snapshot->clear();
    for(int i=0; i<snaps.length(); i++){
       QString comment = POOLDATA.snapshotComment(snaps[i]).simplified();
	if(comment.isEmpty()){ ui->menuDelete_Snapshot->addAction(snaps[i]); }
	else{ ui->menuDelete_Snapshot->addAction(snaps[i] + " (" + comment + ")" ); }
    }
    ui->menuDelete_Snapshot->setEnabled( !ui->menuDelete_Snapshot->isEmpty() );

}
Example #4
0
void createvolume::findInstalledFs()
{
	DialogMsg msg( this ) ;

	QStringList mkfsList =  QDir( QString( ZULUCRYPTmkfs_dir ) ).entryList().filter( "mkfs." ) ;

	if( mkfsList.size() == 0 ){
		disableAll() ;
		QString x = tr( "this tool expects to find file system creation tools at \"%1/\" " ).arg( ZULUCRYPTmkfs_dir ) ;
		x += tr( "and it can not find them.\nIt is therefore not possible to create volumes using this tool." ) ;
		msg.ShowUIOK( tr( "ERROR!" ),x ) ;
		return ;
	}

	int index = mkfsList.indexOf( QString( "mkfs.ext2" ) ) ;
	if( index != -1 ){
		mkfsList.move( index,0 ) ;
	}
	index = mkfsList.indexOf( QString( "mkfs.ntfs" ) ) ;
	if( index != -1 ){
		mkfsList.move( index,0 ) ;
	}
	index = mkfsList.indexOf( QString( "mkfs.vfat" ) ) ;
	if( index != -1 ){
		mkfsList.move( index,0 ) ;
	}
	index = mkfsList.indexOf( QString( "mkfs.ext3" ) ) ;
	if( index != -1 ){
		mkfsList.move( index,0 ) ;
	}
	index = mkfsList.indexOf( QString( "mkfs.ext4" ) ) ;
	if( index != -1 ){
		mkfsList.move( index,0 ) ;
	}
	int j = mkfsList.size() ;
	QStringList mkfs ;
	QString entry ;
	for( int i = 0 ; i < j ; i++ ) {
		entry = mkfsList.at( i ) ;
		mkfs.append( entry.mid( entry.indexOf( "." ) + 1 ) ) ;
	}
	m_ui->comboBoxFS->addItems( mkfs ) ;
}
Example #5
0
QStringList VerifierPrivate::orderChecksumTypes(Verifier::ChecksumStrength strength) const
{
    QStringList checksumTypes;
    if (strength == Verifier::Weak) {
        for (int i = SUPPORTED.count() - 1; i >= 0; --i) {
            checksumTypes.append(SUPPORTED.at(i));
        }
        checksumTypes.move(0, 1); //md4 second position
    } else if (strength == Verifier::Strong) {
        for (int i = SUPPORTED.count() - 1; i >= 0; --i) {
            checksumTypes.append(SUPPORTED.at(i));
        }
        checksumTypes.move(1, checksumTypes.count() - 1); //md5 second last position
        checksumTypes.move(0, checksumTypes.count() - 1); //md4 last position
    } else if (strength == Verifier::Strongest) {
        checksumTypes = SUPPORTED;
    }

    return checksumTypes;
}
void MyPropertyDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
	QString strValue = index.model()->data(index, Qt::EditRole).toString();

	// get field name
	QString * p_strFieldName = static_cast<QString*>(index.internalPointer());

	if (!p_strFieldName)
	{
		qDebug() << "[ERROR] Invalid QString in MyPropertyDelegate::createEditor";
		return;
	}

	if (p_strFieldName->compare("cod_site") == 0)
	{
		QInputDialog * pdialog = qobject_cast<QInputDialog*>(editor);
		QStringList srtlist;
		srtlist.move(srtlist.indexOf(strValue), 0);
		pdialog->setComboBoxItems(srtlist);
	}
	else if (p_strFieldName->compare("cod_area") == 0)
	{
		QInputDialog * pdialog = qobject_cast<QInputDialog*>(editor);
		QStringList srtlist;
		srtlist.move(srtlist.indexOf(strValue), 0);
		pdialog->setComboBoxItems(srtlist);
	}
	else if (p_strFieldName->compare("cod_wu") == 0)
	{
		QInputDialog * pdialog = qobject_cast<QInputDialog*>(editor);
		QStringList srtlist;
		srtlist.move(srtlist.indexOf(strValue), 0);
		pdialog->setComboBoxItems(srtlist);
	}
	else 
	{
		QLineEdit * pedit = qobject_cast<QLineEdit*>(editor);
		pedit->setText(strValue);
	}

}
Example #7
0
static QStringList imageWriteMimeFormats()
{
    QStringList formats;
    QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats();
    for (int i = 0; i < imageFormats.size(); ++i) {
        QString format = QLatin1String("image/");
        format += QString::fromLatin1(imageFormats.at(i).toLower());
        formats.append(format);
    }

    //put png at the front because it is best
    int pngIndex = formats.indexOf(QLatin1String("image/png"));
    if (pngIndex != -1 && pngIndex != 0)
        formats.move(pngIndex, 0);

    return formats;
}
Example #8
0
QString PBIBackend::updateDetails(QString injail){
  QStringList details;
  if(injail.isEmpty() || !RUNNINGJAILS.contains(injail) ){ details = Extras::getCmdOutput("pc-updatemanager pkgcheck"); }
  else{ details = Extras::getCmdOutput("pc-updatemanager -j "+RUNNINGJAILS[injail]+" pkgcheck"); }
  //Now quickly parse the details into a better-organized display output
  for(int i=0; i<details.length(); i++){
    if(details[i].startsWith("Updating repository ") || details[i].startsWith("Upgrades have been requested ") || details[i].contains(" start the upgrade ") ){
      details.removeAt(i);
      i--; //make sure we don't skip a line
    }else if(details[i].contains(" to be downloaded") || details[i].contains(" more space") ){
      details.move(i,0); //move this line to the top
    }else{
      details[i] = details[i].simplified();
    }
  }
  
  return details.join("\n");
}
Example #9
0
/**
* Create a list of file extensions from the given algorithm
* @param algName :: The name of the algorithm
* @param propName :: The name of the property
* @returns A list of file extensions
*/
QStringList
MWRunFiles::getFileExtensionsFromAlgorithm(const QString &algName,
                                           const QString &propName) {
  Mantid::API::IAlgorithm_sptr algorithm =
      Mantid::API::AlgorithmManager::Instance().createUnmanaged(
          algName.toStdString());
  QStringList fileExts;
  if (!algorithm)
    return fileExts;
  algorithm->initialize();
  Property *prop = algorithm->getProperty(propName.toStdString());
  FileProperty *fileProp = dynamic_cast<FileProperty *>(prop);
  MultipleFileProperty *multiFileProp =
      dynamic_cast<MultipleFileProperty *>(prop);

  std::vector<std::string> allowed;
  QString preferredExt;

  if (fileProp) {
    allowed = fileProp->allowedValues();
    preferredExt = QString::fromStdString(fileProp->getDefaultExt());
  } else if (multiFileProp) {
    allowed = multiFileProp->allowedValues();
    preferredExt = QString::fromStdString(multiFileProp->getDefaultExt());
  } else {
    return fileExts;
  }

  std::vector<std::string>::const_iterator iend = allowed.end();
  int index(0);
  for (std::vector<std::string>::const_iterator it = allowed.begin();
       it != iend; ++it) {
    if (!it->empty()) {
      QString ext = QString::fromStdString(*it);
      fileExts.append(ext);
      if (ext == preferredExt) {
        fileExts.move(index, 0);
      }
      ++index;
    }
  }

  return fileExts;
}
void DataManipulationForm::swapColumns(void)
{
	int curr_idx=0, new_idx=0;
	QStringList items;

	curr_idx=new_idx=ord_columns_lst->currentRow();

	if(sender()==move_up_tb)
		new_idx--;
	else
		new_idx++;

	for(int i=0; i < ord_columns_lst->count(); i++)
		items.push_back(ord_columns_lst->item(i)->text());

	items.move(curr_idx, new_idx);
	ord_columns_lst->blockSignals(true);
	ord_columns_lst->clear();
	ord_columns_lst->addItems(items);
	ord_columns_lst->blockSignals(false);
	ord_columns_lst->setCurrentRow(new_idx);
}
Example #11
0
void LPMain::updateTabs(){
  //qDebug() << "Update Tabs" << poolSelected;
  qDebug() << "[DEBUG] start updateTabs():" << poolSelected;
  viewChanged();
  ui->tabWidget->setEnabled(poolSelected);
  ui->menuView->setEnabled(poolSelected);	
  ui->menuDisks->setEnabled(poolSelected); 
  ui->menuSnapshots->setEnabled(poolSelected);
  ui->push_configure->setVisible(poolSelected);
  ui->action_SaveKeyToUSB->setEnabled(poolSelected);
  if(poolSelected){
    showWaitBox(tr("Loading zpool information"));
    qDebug() << "[DEBUG] loadPoolData:" << ui->combo_pools->currentText();
    POOLDATA = LPGUtils::loadPoolData(ui->combo_pools->currentText());
    qDebug() << "[DEBUG] loaded data";
    hideWaitBox();
    //Now list the status information
    ui->label_status->setText(POOLDATA.poolStatus);
    ui->label_numdisks->setText( QString::number(POOLDATA.harddisks.length()) );
    ui->label_latestsnapshot->setText(POOLDATA.latestSnapshot);
    if(POOLDATA.finishedStatus.isEmpty()){ ui->label_finishedstat->setVisible(false); }
    else{
      ui->label_finishedstat->setText(POOLDATA.finishedStatus);
      ui->label_finishedstat->setVisible(true);
    }
    if(POOLDATA.runningStatus.isEmpty()){ 
      ui->label_runningstat->setVisible(false);
      ui->action_startScrub->setEnabled(true);
      ui->action_stopScrub->setEnabled(false);
    }else{
      ui->label_runningstat->setText(POOLDATA.runningStatus);
      ui->label_runningstat->setVisible(true);
      ui->action_startScrub->setEnabled(false); //Something already running
      ui->action_stopScrub->setEnabled(POOLDATA.runningStatus.contains("scrub", Qt::CaseInsensitive));
    }	    
    if(POOLDATA.errorStatus.isEmpty()){ ui->label_errorstat->setVisible(false); }
    else{
      ui->label_errorstat->setText(POOLDATA.errorStatus);
      ui->label_errorstat->setVisible(true);
    }	    
    //Now list the data restore options
    QString cds = ui->combo_datasets->currentText();
    ui->combo_datasets->clear();
    QStringList dslist = POOLDATA.subsets();
    dslist.sort();
    //Now move the home directories to the top of the list
    int moved = 0;
    for(int i=0; i<dslist.length(); i++){  //make sure it stays in alphabetical order
      if(dslist[i].startsWith("/usr/home/")){
        dslist.move(i,moved);
	moved++; 
	i--; //make sure to not miss any items from moving
      }
    }
    ui->combo_datasets->addItems(dslist);
    int dsin = dslist.indexOf(cds);
    if(dsin >= 0){ ui->combo_datasets->setCurrentIndex(dsin); }
    else if( !dslist.isEmpty() ){ ui->combo_datasets->setCurrentIndex(0); }
    else{ ui->combo_datasets->addItem(tr("No datasets available")); }
    //NOTE: this automatically calls the "updateDataset()" function in a new thread
    
    //Now update the snapshot removal menu list
    QStringList snaps = LPBackend::listLPSnapshots(ui->combo_pools->currentText());
    ui->menuDelete_Snapshot->clear();
    for(int i=0; i<snaps.length(); i++){
       ui->menuDelete_Snapshot->addAction(snaps[i]);
    }
    ui->menuDelete_Snapshot->setEnabled( !ui->menuDelete_Snapshot->isEmpty() );
    //Now update the disk menu items
    ui->menuRemove_Disk->clear();
    ui->menuSet_Disk_Offline->clear();
    ui->menuSet_Disk_Online->clear();
    for(int i=0; i<POOLDATA.harddisks.length(); i++){
      ui->menuRemove_Disk->addAction(POOLDATA.harddisks[i]);
      if(POOLDATA.harddiskStatus[i] == "OFFLINE"){
        ui->menuSet_Disk_Online->addAction(POOLDATA.harddisks[i]);
      }else{
	ui->menuSet_Disk_Offline->addAction(POOLDATA.harddisks[i]);      
      }
    }
    ui->menuRemove_Disk->setEnabled(!ui->menuRemove_Disk->isEmpty());
    ui->menuSet_Disk_Offline->setEnabled(!ui->menuSet_Disk_Offline->isEmpty());
    ui->menuSet_Disk_Online->setEnabled(!ui->menuSet_Disk_Online->isEmpty());
  }else{
    //No Pool selected
    ui->label_numdisks->clear();
    ui->label_latestsnapshot->clear();
    ui->label_status->clear();
	  ui->label_errorstat->setVisible(false);
	  ui->label_runningstat->setVisible(false);
	  ui->label_finishedstat->setVisible(false);
  }

}