当前位置: 首页>>代码示例>>C++>>正文


C++ QDir::setPath方法代码示例

本文整理汇总了C++中QDir::setPath方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::setPath方法的具体用法?C++ QDir::setPath怎么用?C++ QDir::setPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDir的用法示例。


在下文中一共展示了QDir::setPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: slotPrintButton

void PDF::slotPrintButton()
{
    QDir monRepertoire;
    bool firstpage = true;
    SeriesInfos.SetChapter(ui->StartChap->value());
    monRepertoire.setPath(SeriesInfos.GetChapterFolder());

    if (monRepertoire.exists())
    {
        QPdfWriter pdfWriter(SeriesInfos.GetSeriesFolder() + "/" + SeriesInfos.GetSeriesName() + " Tome " + SeriesInfos.GetVolume() + ".pdf");
        pdfWriter.setPageSize(QPagedPaintDevice::A4);
        const qreal horizontalMarginMM = 10.0;     // 10 mm margin on each side
        const qreal verticalMarginMM = 10.0;
        QPagedPaintDevice::Margins margins;
        margins.left = margins.right = horizontalMarginMM;
        margins.top = margins.bottom = verticalMarginMM;
        pdfWriter.setMargins(margins);
        QPixmap pixmap;
        QPainter painter;

        while ((monRepertoire.exists()) && (ui->EndChap->value() >= SeriesInfos.GetChapter().toInt()))
        {
            QStringList listOfFiles = monRepertoire.entryList();
            for (int i = 2; i < listOfFiles.size(); i++)
            {
                QString imagePath = monRepertoire.absolutePath() + "/" + listOfFiles.at(i);
                if ((imagePath.contains("jpg")) || (imagePath.contains("png")))
                {
                    pixmap.load(imagePath);
                    if (pixmap.width() >  pixmap.height())
                    {
                        if (ui->Vertical->isChecked())
                        {
                            if (firstpage == false)
                            {
                                pdfWriter.newPage();
                            }
                            else
                            {
                                painter.begin(&pdfWriter);
                            }
                            QTransform t;
                            pixmap = pixmap.transformed(t.rotate(90),Qt::SmoothTransformation);
                            painter.drawPixmap(QRectF(0, 0, pdfWriter.width(), pdfWriter.height()), pixmap, QRectF(0, 0, pixmap.width(), pixmap.height()));
                        }
                        else
                        {
                            pdfWriter.setPageOrientation(QPageLayout::Landscape);
                            if (firstpage == false)
                            {
                                pdfWriter.newPage();
                            }
                            else
                            {
                                painter.begin(&pdfWriter);
                            }
                            painter.drawPixmap(QRectF(0, 0, pdfWriter.width(), pdfWriter.height()), pixmap, QRectF(0, 0, pixmap.width(), pixmap.height()));
                            pdfWriter.setPageOrientation(QPageLayout::Portrait);
                        }
                    }
                    else
                    {
                        if (firstpage == false)
                        {
                            pdfWriter.newPage();
                        }
                        else
                        {
                            painter.begin(&pdfWriter);
                        }
                        painter.drawPixmap(QRectF(0, 0, pdfWriter.width(), pdfWriter.height()), pixmap, QRectF(0, 0, pixmap.width(), pixmap.height()));
                    }
                    firstpage = false;
                }
            }
            SeriesInfos.UpdateChapterVal();
            monRepertoire.setPath(SeriesInfos.GetChapterFolder());
        }

        emit UpdateVolume(CurrentIdx);

        painter.end();
    }
    this->close();
}
开发者ID:BadamBoum,项目名称:GestionScans,代码行数:85,代码来源:pdf.cpp

示例2: interpretResourceFile

bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, QString fname, QString currentPath)
{
    if (!currentPath.isEmpty() && !currentPath.endsWith(QLatin1String("/")))
        currentPath += '/';

    QDomDocument document;
    {
        QString errorMsg;
        int errorLine, errorColumn;
        if(!document.setContent(inputDevice, &errorMsg, &errorLine, &errorColumn)) {
            fprintf(stderr, "pyrcc4 Parse Error:%s:%d:%d [%s]\n", fname.toLatin1().constData(),
                    errorLine, errorColumn, errorMsg.toLatin1().constData());
            return false;
        }
    }
    for(QDomElement root = document.firstChild().toElement(); !root.isNull();
        root = root.nextSibling().toElement()) {
        if (root.tagName() != QLatin1String(TAG_RCC))
            continue;

        for (QDomElement child = root.firstChild().toElement(); !child.isNull();
             child = child.nextSibling().toElement()) {
            if (child.tagName() == QLatin1String(TAG_RESOURCE)) {
                QLocale lang = QLocale::c();
                if (child.hasAttribute(ATTRIBUTE_LANG))
                    lang = QLocale(child.attribute(ATTRIBUTE_LANG));

                QString prefix;
                if (child.hasAttribute(ATTRIBUTE_PREFIX))
                    prefix = child.attribute(ATTRIBUTE_PREFIX);
                if (!prefix.startsWith(QLatin1String("/")))
                    prefix.prepend('/');
                if (!prefix.endsWith(QLatin1String("/")))
                    prefix += '/';


                for (QDomNode res = child.firstChild(); !res.isNull(); res = res.nextSibling()) {
                    if (res.toElement().tagName() == QLatin1String(TAG_FILE)) {

                        QString fileName(res.firstChild().toText().data());
                        if (fileName.isEmpty())
                            fprintf(stderr, "Warning: Null node in XML\n");

                        QString alias;
                        if (res.toElement().hasAttribute(ATTRIBUTE_ALIAS))
                            alias = res.toElement().attribute(ATTRIBUTE_ALIAS);
                        else
                            alias = fileName;

                        int compressLevel = mCompressLevel;
                        if (res.toElement().hasAttribute(ATTRIBUTE_COMPRESS))
                            compressLevel = res.toElement().attribute(ATTRIBUTE_COMPRESS).toInt();
                        int compressThreshold = mCompressThreshold;
                        if (res.toElement().hasAttribute(ATTRIBUTE_THRESHOLD))
                            compressThreshold = res.toElement().attribute(ATTRIBUTE_THRESHOLD).toInt();

                        // Special case for -no-compress. Overrides all other settings.
                        if (mCompressLevel == -2)
                            compressLevel = 0;

                        alias = QDir::cleanPath(alias);
                        while (alias.startsWith("../"))
                            alias.remove(0, 3);
                        alias = prefix + alias;

                        QFileInfo file(currentPath + fileName);
                        if (!file.exists()) {
                            fprintf(stderr, "Cannot find file: %s\n", fileName.toLatin1().constData());
                            continue ;
                        } else if (file.isFile()) {
                            addFile(alias, RCCFileInfo(alias.section('/', -1), file, lang,
                                                       RCCFileInfo::NoFlags, compressLevel, compressThreshold));
                        } else {
                            QDir dir;
                            if(file.isDir()) {
                                dir.setPath(file.filePath());
                            } else {
                                dir.setPath(file.path());
                                dir.setNameFilters(QStringList(file.fileName()));
                                if(alias.endsWith(file.fileName()))
                                    alias = alias.left(alias.length()-file.fileName().length());
                            }
                            if (!alias.endsWith(QLatin1String("/")))
                                alias += '/';
                            QFileInfoList children = dir.entryInfoList();
                            for(int i = 0; i < children.size(); ++i) {
                                if(children[i].fileName() != QLatin1String(".") &&
                                   children[i].fileName() != QLatin1String(".."))
                                    addFile(alias + children[i].fileName(),
                                            RCCFileInfo(children[i].fileName(), children[i], lang,
                                                        RCCFileInfo::NoFlags, compressLevel, compressThreshold));
                            }
                        }
                    }
                }
            }
        }
    }
    if(this->root == 0) {
        fprintf(stderr, "No resources in resource description.\n");
//.........这里部分代码省略.........
开发者ID:AlexDoul,项目名称:PyQt4,代码行数:101,代码来源:rcc.cpp

示例3: HandleImport

void IconView::HandleImport(void)
{
    QFileInfo path;
    QDir importdir;

    // Makes import directory samba/windows friendly (no colon)
    QString idirname = m_currDir + "/" +
        MythDate::current().toString("yyyy-MM-dd_hh-mm-ss");

    importdir.mkdir(idirname);
    importdir.setPath(idirname);

    for (QStringList::const_iterator it = m_paths.begin();
         it != m_paths.end(); ++it)
    {
        path.setFile(*it);
        if (path.isDir() && path.isReadable())
        {
            ImportFromDir(*it, importdir.absolutePath());
        }
        else if (path.isFile() && path.isExecutable())
        {
            if (m_allowImportScripts)
            {
                QString cmd = *it + " " + importdir.absolutePath();

                MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
                MythUIBusyDialog *busy =
                        new MythUIBusyDialog(tr("Importing images from camera. Please wait..."),
                                                popupStack,
                                                "importbusydialog");

                if (busy->Create())
                {
                    popupStack->AddScreen(busy, false);
                }
                else
                {
                    delete busy;
                    busy = NULL;
                }

                ImportThread *import = new ImportThread(cmd);
                import->start();

                while (!import->isFinished())
                {
                    usleep(500);
                    qApp->processEvents();
                }

                delete import;

                if (busy)
                    busy->Close();
            }
            else
            {
                ShowOkPopup(tr("Found an import script (%1) but running them has been disabled in the settings!")
                               .arg(*it));
                importdir.rmdir(importdir.absolutePath());
                return;
            }
        }
        else
        {
            LOG(VB_GENERAL, LOG_ERR, LOC +
                QString("Could not read or execute %1").arg(*it));

            ShowOkPopup(tr("Could not read or execute %1").arg(*it));
        }
    }

    importdir.setFilter(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot);
    importdir.refresh();
    if (importdir.count() == 0)
    {
        ShowOkPopup(tr("Nothing found to import"));
        importdir.rmdir(importdir.absolutePath());
        return;
    }
    else
        ShowOkPopup(tr("Found %n image(s)", "", importdir.count()));

    LoadDirectory(m_currDir);
}
开发者ID:DaveDaCoda,项目名称:mythtv,代码行数:86,代码来源:iconview.cpp

示例4: ParseOptions


//.........这里部分代码省略.........
            {
                pOptions->sDataBasePath=sTemp;
            }
            else
            {
                printf("Invalid database name: %s",sTemp.toAscii().data());
                return false;
            }
        }
        else
        {
            listTemp1.append(sParam);
        }
    }

    if(listTemp1.count()==0)
    {
        printf("No file specified");

        return false;
    }

    QFile file;
    QDir dir;

    //    QDir dir2;
    //    int nNumberOfSlash=0;
    //    QStringList listTemp2;
    //    QFileInfoList fil;
    //    QString sBaseName;
    for(int i=0; i<listTemp1.count(); i++)
    {
        file.setFileName(listTemp1.at(i));
        dir.setPath(listTemp1.at(i));

        if(listTemp1.at(i)==".")
        {
            continue;
        }
        else if(listTemp1.at(i)=="..")
        {
            continue;
        }
        else if(dir.exists())
        {
            FindFiles(listTemp1.at(i),pListFiles,pOptions->bScanSubfolders);
        }
        else if(file.exists())
        {
            pListFiles->append(listTemp1.at(i));
        }
        else if(listTemp1.at(i).contains("*")||listTemp1.at(i).contains("?"))
        {
            QStringList nameFilters;
            nameFilters.append(listTemp1.at(i));
            QDir _dir;
            QFileInfoList listFI=_dir.entryInfoList(nameFilters);


            for(int j=0; j<listFI.count(); j++)
            {
                if(listFI.at(j).isDir())
                {
                    FindFiles(listFI.at(j).absoluteFilePath(),pListFiles,pOptions->bScanSubfolders);
                }
                else if(listFI.at(j).isFile())
开发者ID:BackTrackCRoot,项目名称:DIE-engine,代码行数:67,代码来源:mainc.cpp

示例5: hyphDirs

QStringList ScPaths::hyphDirs() const
{
	//dictionaryPaths
	QString macPortsPath("/opt/local/share/hunspell/");
	QString finkPath("/sw/share/hunspell/");
	QString osxLibreOfficePath("/Applications/LibreOffice.app/Contents/Resources/extensions");
	QString osxUserLibreOfficePath(QDir::homePath()+"/Applications/LibreOffice.app/Contents/Resources/extensions");
	QString linuxLocalPath("/usr/local/share/hunspell/");
	QString linuxHunspellPath("/usr/share/hunspell/");
	QString linuxMyspellPath("/usr/share/myspell/");
	QString linuxHyphen1Path("/usr/share/hyphen/");
	QString windowsLOPath("LibreOffice 3.5/share/extensions");
	QDir d;
	QStringList hyphDirs;
	hyphDirs.append(userDictDir(ScPaths::Hyph, false));
	hyphDirs.append(m_shareDir + "dicts/hyph/");
#ifdef Q_OS_MAC
	d.setPath(macPortsPath);
	if (d.exists())
		hyphDirs.append(macPortsPath);
	d.setPath(finkPath);
	if (d.exists())
		hyphDirs.append(finkPath);
	d.setPath(osxLibreOfficePath);
	if (d.exists())
	{
		QStringList dictDirFilters("dict-*");
		QStringList dictDirList(d.entryList(dictDirFilters, QDir::Dirs, QDir::Name));
		QString dir;
		foreach (dir, dictDirList)
			hyphDirs.append(osxLibreOfficePath + "/" + dir + "/");
	}
	d.setPath(osxUserLibreOfficePath);
	if (d.exists())
	{
		QStringList dictDirFilters("dict-*");
		QStringList dictDirList(d.entryList(dictDirFilters, QDir::Dirs, QDir::Name));
		QString dir;
		foreach (dir, dictDirList)
			hyphDirs.append(osxUserLibreOfficePath + "/" + dir + "/");
	}

#elif defined(_WIN32)
	QString progFiles = windowsSpecialDir(CSIDL_PROGRAM_FILES);
	d.setPath(progFiles+windowsLOPath);
	if (d.exists())
	{
		QStringList dictDirFilters("dict-*");
		QStringList dictDirList(d.entryList(dictDirFilters, QDir::Dirs, QDir::Name));
		QString dir;
		foreach (dir, dictDirList)
			hyphDirs.append(progFiles+windowsLOPath + "/" + dir + "/");
	}
#elif defined(Q_OS_LINUX)
	d.setPath(linuxHyphen1Path);
	if (d.exists())
		hyphDirs.append(linuxHyphen1Path);
	d.setPath(linuxHunspellPath);
	if (d.exists())
		hyphDirs.append(linuxHunspellPath);
	d.setPath(linuxMyspellPath);
	if (d.exists())
		hyphDirs.append(linuxMyspellPath);
	d.setPath(linuxLocalPath);
	if (d.exists())
		hyphDirs.append(linuxLocalPath);
#endif
	return hyphDirs;
}
开发者ID:Fahad-Alsaidi,项目名称:scribus-svn,代码行数:69,代码来源:scpaths.cpp

示例6: QDialog

SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent),
  ui(new Ui::SettingsDialog) {
  ui->setupUi(this);

  // autodetect paths

  SteamConfig steam;

  QString baseInstall = steam["software/valve/steam/baseinstallfolder_1"];

  QDir steamDir = QDir(baseInstall);
  // check if the path is empty before calling anything that acts on it
  // otherwise qdir complains
  if (baseInstall.isEmpty() || !steamDir.exists()) {
    // find the OS's application folder
    steamDir.setPath(QStandardPaths::standardLocations(
          QStandardPaths::ApplicationsLocation).first());
    steamDir.setPath(steamDir.absoluteFilePath("Steam"));
  }
  if (!steamDir.exists()) {
    // find the home folder
    steamDir.setPath(QStandardPaths::standardLocations(
          QStandardPaths::GenericDataLocation).first());
    steamDir.setPath(steamDir.absoluteFilePath("Steam"));
  }

  QString installDir = steam["software/valve/steam/apps/105600/installdir"];
  QDir terrariaDir = QDir(installDir);
  if (installDir.isEmpty() || !terrariaDir.exists())
    terrariaDir.setPath(steamDir.absoluteFilePath("SteamApps/common/Terraria"));

  defaultTextures = "";
  if (terrariaDir.exists())
    defaultTextures = terrariaDir.absoluteFilePath("Content/Images");

  QDir worldDir = QDir(
        QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)
        .first());
  worldDir.setPath(worldDir.absoluteFilePath("My Games/Terraria/Worlds"));
  if (!worldDir.exists()) {
    // try linux path
    worldDir.setPath(QStandardPaths::standardLocations(
                          QStandardPaths::GenericDataLocation).first());
    worldDir.setPath(worldDir.absoluteFilePath("Terraria/Worlds"));
  }

  QStringList steamWorldDirs;
  QDir userDir = QDir(steamDir.absoluteFilePath("userdata"));
  for (const QFileInfo dir : userDir.entryInfoList(QDir::NoDotAndDotDot |
                                                   QDir::Dirs)) {
    QString steamWorldDir = QDir(dir.absoluteFilePath()).
        absoluteFilePath("105600/remote/worlds");
    if (QDir(steamWorldDir).exists())
      steamWorldDirs += steamWorldDir;
  }

  defaultSaves = QStringList(worldDir.absolutePath()) + steamWorldDirs;

  QSettings info;
  useDefSave = info.value("useDefSave", true).toBool();
  customSave = info.value("customSave", defaultSaves[0]).toString();
  useDefTex = info.value("useDefTex", true).toBool();
  customTextures = info.value("customTextures", defaultTextures).toString();
}
开发者ID:biouxtai,项目名称:TerraFirma,代码行数:64,代码来源:settingsdialog.cpp

示例7: findInPath

void favoritos::findInPath()
{

     QString xdgDataDirs;
     char *xdgDataDirsEnv = getenv("XDG_DATA_DIRS");

     if(xdgDataDirsEnv != NULL)
     {
        xdgDataDirs = xdgDataDirsEnv;
     }
     else
     {
        xdgDataDirs = "/usr/local/share/:/usr/share/";
     }

     QStringList folderSplit = xdgDataDirs.split(':');
     QStringList folders;

     QDir dir;

     for(int countDirs = 0;  countDirs < folderSplit.size(); ++countDirs)
     {
         if(folderSplit[countDirs].right(1) != "/")
            folderSplit[countDirs] = folderSplit[countDirs] + "/applications";
         else
            folderSplit[countDirs] = folderSplit[countDirs] + "applications";

         dir.setPath(folderSplit[countDirs]);
         if(dir.exists())
            folders << folderSplit[countDirs];

     }

     folders.removeDuplicates();

     QList<QString> listFavApps;

//Escritório
     listFavApps.append("libreoffice-writer.desktop");
     listFavApps.append("libreoffice-calc.desktop");
     listFavApps.append("libreoffice-impress.desktop");
     listFavApps.append("libreoffice-draw.desktop");
/*
     if(plataforma == "xfce")
     {
      xfce4-settings-manager
     }
*/

//Gráficas
     listFavApps.append("gimp.desktop");
     listFavApps.append("inkscape.desktop");
     listFavApps.append("xsane.desktop");
//Internet
     listFavApps.append("google-chrome.desktop");
     listFavApps.append("firefox.desktop");
     listFavApps.append("brasero.desktop");
     listFavApps.append("chromium-browser.desktop");
//Multimídia
     listFavApps.append("vlc.desktop");
     listFavApps.append("vlc.desktop");

//xdg-open detectDE
/*
     if(plataforma == "xfce")
     {
      xfce4-settings-manager
     }

*/
     listFavApps.append("configurações");
     listFavApps.append("calculadora");
     listFavApps.append("gerenciador de arquivos");
     listFavApps.append("terminal");
     listFavApps.append("tocador de audio/vídeo");
     listFavApps.append("k3b");



     for(int countItens = 0;  countItens <= 12; ++countItens)
     {

         foreach(const QString& path, folders)
         {
             QDir dir(path);

             QFileInfoList fileInfos = dir.entryInfoList(QStringList("*.desktop"), QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Files);

             foreach(const QFileInfo& fileInfo, fileInfos)
             {
                  if(listFavApps.at(countItens) == fileInfo.fileName())
                     readFile(fileInfo.filePath());
             }
         }
     }
开发者ID:jeanrl,项目名称:cdash,代码行数:95,代码来源:favoritos.cpp

示例8: hide


//.........这里部分代码省略.........
{
    ui->saveLabel->clear();
    //TODO plain to QString*
    //-> problem bei im->hide_1Bit
    QString plain;
    if(ui->textFromDocRadio->isChecked())
    {
        QString plainPath = ui->textPathTextField->text();
        QFile file(plainPath);
        file.open(QIODevice::ReadOnly | QIODevice::Text);
        QTextStream in(&file);
        plain = in.readAll();
        file.close();
    } else if(ui->textFromFieldRadio->isChecked()) plain = ui->textEdit->toPlainText(); //if(textFromFieldRadio)

    //encrypt
    if(ui->encryptCheckBox->isChecked())
    {
        ui->saveLabel->setText("Encrypting...");
        plain = *(encrypt(&plain));
        ui->saveLabel->clear();
    }

    QString oldPath = ui->picPathTextField->text();
    im = new Intermediary(oldPath);
    if(ui->textFromDocRadio->isChecked() && ui->textPathTextField->text().endsWith(".png"))
    {
        im->setImage(ui->textPathTextField->text());
    } else {
        im->setText(&plain,format);
    }
    QString savePath;

    ui->saveLabel->setText("Hiding...");
    if(im->isReady_1Bit())
    {
        savePath = QFileDialog::getSaveFileName(this, tr("Save File"), actDir.absolutePath(), tr("*.png *.jpg"));
        im->hide_1Bit(savePath);
    } else {
        int action = popupProblemDialog();
        qDebug()<<action;
        while(action != CANCEL)
        {

            if( action == DENSITY) {
                int w = noiseWarningDialog();
                if(im->isReady_3Bit() && w == 1)
                {
                    savePath = QFileDialog::getSaveFileName(this, tr("Save File"), actDir.absolutePath(), tr("*.png *.jpg"));
                    im->hide_3Bit(savePath);
                    action = CANCEL;
                } else {
                    action = popupProblemDialog();
                    if( action == DENSITY)
                    {
                        w = noiseWarningDialog();
                        if(im->isReady_3Bit() && w == 1)
                        {
                            savePath = QFileDialog::getSaveFileName(this, tr("Save File"), actDir.absolutePath(), tr("*.png *.jpg"));
                            im->hide_6Bit(savePath);
                            action = CANCEL;
                        } else {
                            notEnough();
                            action = CANCEL;
                        }
                    }
                }
            }
            else if(action == PICS)
            {
                apd = new AddPicDialog(im);
                apd->setActDir(actDir.absolutePath());
                apd->exec();
                action = CANCEL;
            } else if(action == NEWPIC)
            {
                im->images->remove(savePath);
                chosePicture();
                im->addImage(ui->picPathTextField->text());
                if(im->isReady_1Bit()) {
                    savePath = QFileDialog::getSaveFileName(this, tr("Save File"), actDir.absolutePath(), tr("*.png *.jpg"));
                    im->hide_1Bit(savePath);
                    action = CANCEL;
                } else {
                    action = popupProblemDialog();
                }
            } else {
                action=CANCEL;
            }
        }
    }
    ui->saveLabel->clear();
    ui->picPathTextField_2->clear();
    if(!savePath.isEmpty())
    {
        actDir.setPath(savePath);
        ui->picPathTextField_2->addItem(savePath);
        showSuccessfulHiding(savePath);
    }
}
开发者ID:banditos,项目名称:Steganography,代码行数:101,代码来源:mainwindow.cpp

示例9: find

//********************************************************************
//
// Method: find
// Parameter: none, read input
//          create instance of Intermediary
//
// Purpose: use Intermediary to find, output found text or picture
//
//********************************************************************
void MainWindow::find()
{
    QString path = ui->picPathTextField_2->item(0)->text();
    im = new Intermediary(path);
    for(int index = 1; index < (ui->picPathTextField_2->count()); index++)
    {
        im->addImage(ui->picPathTextField_2->item(index)->text());
    }

    if(im->imageOrTextHidden() == 1) //1 => text, 0 => picture
    {
        qDebug("Hidden text found.");
        QString* plain = im->getHiddenText();
        //decrypt
        if(ui->decryptCheckBox->isChecked())
        {
            plain = decrypt(plain);
        }
        if(ui->textToFieldRadio->isChecked())
        {
            ui->picField->clear();
            ui->textEdit_2->setText(*plain);
        } else if(ui->textToDocRadio->isChecked())
        {
            QString newPath = QFileDialog::getSaveFileName(
                                  this,
                                  "Save Textfile",
                                  actDir.absolutePath(),
                                  "Text Files(*.txt)");
            actDir.setPath(newPath);
            QFile fileOut(newPath);
            if (fileOut.open(QIODevice::WriteOnly | QIODevice::Text))
            {
                QTextStream streamFileOut(&fileOut);
                streamFileOut.setCodec("UTF-8");
                streamFileOut.setGenerateByteOrderMark(true);
                streamFileOut << *plain;
                streamFileOut.flush();
                fileOut.close();
            }
        }
    }
    else if(im->imageOrTextHidden() == 0)
    {
        qDebug("Hidden image found.");
        QImage* image;
        image = im->getHiddenImage();
        if(ui->textToFieldRadio->isChecked())
        {
            ui->textEdit_2->clear();
            QPixmap img = QPixmap::fromImage(*image);
            if (img.height() > ui->picField->height() && img.width() > ui->picField->width())
            {
                img = img.scaled(ui->picField->width(), ui->picField->height());
            }
            else if(img.height() > ui->picField->height())
            {
                img = img.scaledToHeight(ui->picField->height());
            }
            else if(img.width() > ui->picField->width())
            {
                img = img.scaledToWidth(ui->picField->width());
            }
            ui->picField->setPixmap(img);
        }
        else {
            QString newPath = QFileDialog::getSaveFileName(
                                  this,
                                  "Save Image",
                                  actDir.absolutePath(),
                                  "Image Files(*.png)");
            actDir.setPath(newPath);
            image->save(newPath,"PNG",100);
        }
    }
    ui->saveLabel->clear();
}
开发者ID:banditos,项目名称:Steganography,代码行数:86,代码来源:mainwindow.cpp

示例10: load

int PluginManager::load() {
    Logger::log("PluginManager::load(): Loading plugins modified since "
                + m_lastLoaded.toString(Qt::ISODate), Logger::LowVerbosity);
    int count = 0;
    QDir dir;
    
    foreach (const QString &path, PLUGIN_PATHS) {
        dir.setPath(path);
        
        foreach (const QFileInfo &info, dir.entryInfoList(QStringList() << "*.json", QDir::Files, QDir::Time)) {
            if (info.lastModified() > m_lastLoaded) {
                ServicePluginConfig *config = getConfigByFilePath(info.absoluteFilePath());
                
                if (!config) {
                    config = new ServicePluginConfig(this);
                    
                    if (config->load(info.absoluteFilePath())) {
                        if (config->pluginType() == "qt") {
                            QPluginLoader loader(config->pluginFilePath());
                            QObject *obj = loader.instance();
                            
                            if (obj) {
                                if (ServicePlugin *plugin = qobject_cast<ServicePlugin*>(obj)) {
                                    m_plugins << ServicePluginPair(config, plugin);
                                    ++count;
                                    Logger::log("PluginManager::load(). Qt Plugin loaded: " + config->id(),
                                                Logger::MediumVerbosity);
                                }
                                else {
                                    loader.unload();
                                    Logger::log("PluginManager::load(). Error loading Qt plugin: "
                                                + config->id());
                                }
                            }
                            else {
                                Logger::log("PluginManager::load(). Qt plugin is NULL: " + config->id());
                            }
                        }
                        else if (config->pluginType() == "js") {
                            JavaScriptServicePlugin *js =
                            new JavaScriptServicePlugin(config->id(), config->pluginFilePath(), this);
                            m_plugins << ServicePluginPair(config, js);
                            ++count;
                            Logger::log("PluginManager::load(). JavaScript plugin loaded: " + config->id(),
                                        Logger::MediumVerbosity);
                        }
                        else {
                            ExternalServicePlugin *ext =
                            new ExternalServicePlugin(config->id(), config->pluginFilePath(), this);
                            m_plugins << ServicePluginPair(config, ext);
                            ++count;
                            Logger::log("PluginManager::load(). External plugin loaded: " + config->id(),
                                        Logger::MediumVerbosity);
                        }
                    }
                    else {
                        delete config;
                    }
                }
            }
            else {
                break;
            }
        }
    }
开发者ID:marxoft,项目名称:musikloud2,代码行数:65,代码来源:pluginmanager.cpp

示例11: on_duplicateButton_clicked

/**Duplicates selected macro
 * New file has same name as original but with "@" and 3-digit number appended
 * Begins with "@001" and increments until available name is found
 * "MyMacro.FCMacro" becomes "[email protected]"
 * "[email protected]" becomes "[email protected]" unless there is
 * no already existing "[email protected]"
 */
void DlgMacroExecuteImp::on_duplicateButton_clicked()
{
    QDir dir;
    QTreeWidgetItem* item = 0;

    int index = tabMacroWidget->currentIndex();
    if (index == 0) { //user-specific
        item = userMacroListBox->currentItem();
        dir.setPath(this->macroPath);
    }

    if (!item){
        return;
    }

    QString oldName = item->text(0);
    QFileInfo oldfi(dir, oldName);
    QFile oldfile(oldfi.absoluteFilePath());
    QString completeSuffix = oldfi.completeSuffix(); //everything after the first "."
    QString baseName = oldfi.baseName(); //everything before first "."
    QString neutralSymbol = QString::fromStdString("@");
    QString last3 = baseName.right(3);
    bool ok = true; //was conversion to int successful?
    int nLast3 = last3.toInt(&ok);
    last3 = QString::fromStdString("001"); //increment beginning with 001 no matter what
    if (ok ){
        //last3 were all digits, so we strip them from the base name
        if (baseName.size()>3){ //if <= 3 leave be (e.g. 2.py becomes [email protected])
            baseName = baseName.left(baseName.size()-3); //strip digits
            if (baseName.endsWith(neutralSymbol)){
                baseName = baseName.left(baseName.size()-1); //trim the "@", will be added back later
            }
        }
    }
    //at this point baseName = the base name without any digits, e.g. "MyMacro"
    //neutralSymbol = "@"
    //last3 is a string representing 3 digits, always "001" at this time
    //completeSuffix = FCMacro or py or FCMacro.py or else suffix will become FCMacro below

    QString oldNameDigitized = baseName+neutralSymbol+last3+QString::fromStdString(".")+completeSuffix;
    QFileInfo fi(dir, oldNameDigitized);
    // increment until we find available name with smallest digits
    // test from "001" through "999", then give up and let user enter name of choice
    while (fi.exists()) {
        nLast3 = last3.toInt()+1;
        if (nLast3 >=1000){ //avoid infinite loop, 999 files will have to be enough
            break;
        }
        last3 = QString::number(nLast3);
        while (last3.size()<3){
            last3.prepend(QString::fromStdString("0")); //pad 0's if needed
        }
        oldNameDigitized = baseName+neutralSymbol+last3+QString::fromStdString(".")+completeSuffix;
        fi = QFileInfo(dir,oldNameDigitized);
    }

    // give user a chance to pick a different name from digitized name suggested
    QString fn = QInputDialog::getText(this, tr("Duplicate Macro"),
        tr("Enter new name:"), QLineEdit::Normal, oldNameDigitized, 0);
    if (!fn.isEmpty() && fn != oldName) {
        QString suffix = QFileInfo(fn).suffix().toLower();
        if (suffix != QLatin1String("fcmacro") && suffix != QLatin1String("py")){
            fn += QLatin1String(".FCMacro");
        }
        QFileInfo fi(dir, fn);
        // check again if new name exists in case user changed it
        if (fi.exists()) {
            QMessageBox::warning(this, tr("Existing file"),
                tr("'%1'\n already exists.").arg(fi.absoluteFilePath()));
        }
        else if (!oldfile.copy(fi.absoluteFilePath())) {
            QMessageBox::warning(this, tr("Duplicate Failed"),
                tr("Failed to duplicate to '%1'.\nPerhaps a file permission error?").arg(fi.absoluteFilePath()));
        }

        this->fillUpList(); //repopulate list to show new file
    }

}
开发者ID:WandererFan,项目名称:FreeCAD,代码行数:86,代码来源:DlgMacroExecuteImp.cpp

示例12: main

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    //Command line arguments
    TCLAP::CmdLine cmd("GOBLET (c) 2012, International Livestock Research Institute (ILRI) \n Developed by Carlos Quiros ([email protected])", ' ', "1.0 (Beta 1)");
    //Required arguments
    TCLAP::ValueArg<std::string> databaseArg("d","database","Database name",true,"","string");
    TCLAP::ValueArg<std::string> calculationArg("c","calculation","Calculation to perform. For example: 'sum(DatasetA),sum(DatasetB)' ",true,"","string");    
    TCLAP::ValueArg<std::string> shapeArg("s","shapefile","Shapefile to use",true,"","string");



    //Non required arguments
    TCLAP::ValueArg<std::string> pathArg("a","path","Path to database. Default .",false,".","string");
    TCLAP::ValueArg<std::string> hostArg("H","host","Connect to host. Default localhost",false,"localhost","string");
    TCLAP::ValueArg<std::string> portArg("P","port","Port number to use. Default 3306",false,"3306","string");
    TCLAP::ValueArg<std::string> userArg("u","user","User. Default empty",false,"","string");
    TCLAP::ValueArg<std::string> passArg("p","password","Passwork. Default no password",false,"","string");
    TCLAP::ValueArg<std::string> descArg("S","descriptions","Descriptions for the calculations separated by coma. Default value is the calculation string",false,"","string");
    TCLAP::ValueArg<std::string> fieldArg("f","fields","Field of shapefile to include in result separared by coma. Default value all",false,"all","string");
    TCLAP::ValueArg<std::string> whereArg("w","where","WHERE statement for shapefile",false,"","string");
    TCLAP::ValueArg<std::string> groupArg("g","group","GROUP fields statements for shapefile",false,"","string");
    TCLAP::ValueArg<std::string> ouputArg("t","outputType","Output type: (h)uman readable or (c)omputer readable",false,"h","string");
    TCLAP::ValueArg<std::string> outputFileArg("o","outputFile","If output type is computer, output xml file. Default ./executesql_out.xml",false,"./executesql_out.xml","string");

    //Switches
    TCLAP::SwitchArg remoteSwitch("r","remote","Connect to remote host", cmd, false);
    cmd.add(databaseArg);
    cmd.add(calculationArg);
    cmd.add(ouputArg);
    cmd.add(shapeArg);
    cmd.add(whereArg);
    cmd.add(groupArg);


    cmd.add(pathArg);
    cmd.add(hostArg);
    cmd.add(portArg);
    cmd.add(userArg);
    cmd.add(passArg);
    cmd.add(descArg);
    cmd.add(fieldArg);
    cmd.add(outputFileArg);


    //Parsing the command lines
    cmd.parse( argc, argv );

    //Getting the variables from the command
    bool remote = remoteSwitch.getValue();
    QString path = QString::fromUtf8(pathArg.getValue().c_str());
    QString dbName = QString::fromUtf8(databaseArg.getValue().c_str());
    QString host = QString::fromUtf8(hostArg.getValue().c_str());
    QString port = QString::fromUtf8(portArg.getValue().c_str());
    QString userName = QString::fromUtf8(userArg.getValue().c_str());
    QString password = QString::fromUtf8(passArg.getValue().c_str());
    QString calculation = QString::fromUtf8(calculationArg.getValue().c_str());
    QString format = QString::fromUtf8(ouputArg.getValue().c_str());
    QString description = QString::fromUtf8(descArg.getValue().c_str());
    QString shape = QString::fromUtf8(shapeArg.getValue().c_str());
    QString cmdWhere = QString::fromUtf8(whereArg.getValue().c_str());
    QString cmdgroup = QString::fromUtf8(groupArg.getValue().c_str());
    QString strfields = QString::fromUtf8(fieldArg.getValue().c_str());
    QString outfile = QString::fromUtf8(outputFileArg.getValue().c_str());


    myDBConn con;
    QSqlDatabase mydb;
    if (!remote)
    {
        QDir dir;
        dir.setPath(path);
        if (con.connectToDB(dir.absolutePath()) == 1)
        {
            if (!dir.cd(dbName))
            {
                gbtLog(QObject::tr("The database does not exists"));
                con.closeConnection();
                return 1;
            }
            mydb = QSqlDatabase::addDatabase(con.getDriver(),"connection1");
        }
    }
    else
    {
        mydb = QSqlDatabase::addDatabase("QMYSQL","connection1");
        mydb.setHostName(host);
        mydb.setPort(port.toInt());
        if (!userName.isEmpty())
           mydb.setUserName(userName);
        if (!password.isEmpty())
           mydb.setPassword(password);
    }

    mydb.setDatabaseName(dbName);

    if (!mydb.open())
    {
        gbtLog(QObject::tr("Cannot open database"));
        con.closeConnection();
//.........这里部分代码省略.........
开发者ID:qlands,项目名称:GOBLET,代码行数:101,代码来源:main.cpp

示例13: main

int main(int argc, char ** argv)
{
#ifdef DEBUG
    QsLogging::Logger & logger = QsLogging::Logger::instance();
    logger.setLoggingLevel(QsLogging::TraceLevel);
    QDir dir;
    dir.setPath(qApp->applicationDirPath());
    dir.remove(QString("cpp_utils") + QString(".log"));
    const QString sLogPath(QDir(qApp->applicationDirPath()).filePath(QString("cpp_generator") + QString(".log")));
    QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination(sLogPath));
    QsLogging::DestinationPtr debugDestination(QsLogging::DestinationFactory::MakeDebugOutputDestination());
    logger.addDestination(debugDestination.get());
    logger.addDestination(fileDestination.get());

    QSettings settings(QSettings::IniFormat, QSettings::UserScope, "DoUML", "settings");
    settings.setIniCodec(QTextCodec::codecForName("UTF-8"));
    QString locale = settings.value("Main/encoding").toString();
    QTextCodec* codec = QTextCodec::codecForName(locale.toLatin1().constData());
    QTextCodec::setCodecForLocale(codec);

    QLOG_INFO() << " STARTING CPP_GENERATOR";

#endif
    //QTest::qSleep(7000);
    int port_index;
#ifndef _RUN_PLUGOUT_EXTERNAL_
    if (argc == 2) {
        port_index = 1;
        QLOG_INFO() << "Got two arguments from Douml as argv";
        QLOG_INFO() << "Using first port index mode";
    }
    else if (argc == 3) {
        QLOG_INFO() << "Got three arguments from Douml as argv";
        if (argv[1][1] == 'v') {
            QLOG_INFO() << "Using verbose mode";
            set_verbose();
        }
        else {
            QLOG_INFO() << "Using preserve mode";
            set_preserve();
        }
        QLOG_INFO() << "Using second port index mode";
        port_index = 2;
    }
    else if (argc == 4) {
        QLOG_INFO() << "Got four arguments from Douml as argv";
        QLOG_INFO() << "Using preserve mode";
        QLOG_INFO() << "Using verbose mode";
        QLOG_INFO() << "Using third port index mode";
        set_verbose();
        set_preserve();
        port_index = 3;
    }
    else {
        QLOG_INFO() << "Got too little or too much arguments from Douml, exiting";
        return 0;
    }
    if (UmlCom::connect(QString(argv[port_index]).toUInt())) {
#else
    port_index = 1;
    if (UmlCom::connect(5000)) {
#endif
        try {

            UmlCom::trace("<b>C++ generator</b> release 2.18<br>");
            UmlCom::traceAutoRaise(FALSE);
            UmlCom::targetItem()->generate();

            QString s;

            s = "<hr><font face=helvetica>Generation done : %1 warnings, %2 errors</font><br>";
            s=s.arg(QString::number(n_warnings())).arg(QString::number(n_errors()));

            UmlCom::trace(s.toLatin1().constData());

            UmlCom::showTrace();
            UmlCom::message("");

            UmlCom::bye(n_errors());
        }
        catch (...) {
            QLOG_INFO() << "unhandled exception caught";
        }
    }

    UmlCom::close();
    return 0;
}
开发者ID:ErickCastellanos,项目名称:douml,代码行数:88,代码来源:main.cpp

示例14: HandleImport

void IconView::HandleImport(void)
{
    QFileInfo path;
    QDir importdir;

#if 0
    DialogBox *importDlg = new DialogBox(GetMythMainWindow(),
                                         tr("Import pictures?"));

    importDlg->AddButton(tr("No"));
    importDlg->AddButton(tr("Yes"));
    DialogCode code = importDlg->exec();
    importDlg->deleteLater();
    if (kDialogCodeButton1 != code)
        return;
#endif

    // Makes import directory samba/windows friendly (no colon)
    QString idirname = m_currDir + "/" +
        MythDate::current().toString("yyyy-MM-dd_hh-mm-ss");

    importdir.mkdir(idirname);
    importdir.setPath(idirname);

    for (QStringList::const_iterator it = m_paths.begin();
         it != m_paths.end(); ++it)
    {
        path.setFile(*it);
        if (path.isDir() && path.isReadable())
        {
            ImportFromDir(*it, importdir.absolutePath());
        }
#if 0
        else if (path.isFile() && path.isExecutable())
        {
            // TODO this should not be enabled by default!!!
            QString cmd = *it + " " + importdir.absolutePath();
            LOG(VB_GENERAL, LOG_INFO, LOC + QString("Executing %1").arg(cmd));
            myth_system(cmd);
        }
#endif
        else
        {
            LOG(VB_GENERAL, LOG_ERR, LOC +
                QString("Could not read or execute %1").arg(*it));
        }
    }

    importdir.refresh();
    if (importdir.count() == 0)
    {
#if 0
        DialogBox *nopicsDlg = new DialogBox(GetMythMainWindow(),
                                             tr("Nothing found to import"));

        nopicsDlg->AddButton(tr("OK"));
        nopicsDlg->exec();
        nopicsDlg->deleteLater();
#endif

        return;
    }

    LoadDirectory(m_currDir);
}
开发者ID:iainlane,项目名称:mythtv,代码行数:65,代码来源:iconview.cpp

示例15: populateListbox

void ThemesDlg::populateListbox()
{
    ThemeWidget* item;
    QDir dir;
    QStringList dirs;
    QStringList t;
    KStandardDirs ksd;

    tableThemes->clear();

    item = new ThemeWidget;

    item->iconLabel->setPixmap(KIconLoader::global()->loadIcon("get-hot-new-stuff",
                               KIconLoader::NoGroup, KIconLoader::SizeHuge));
    item->setHeaderText(i18n("Get New Stuff"));
    item->setDescriptionText(i18n("Download new themes."));

    item->buttonGo->setText(i18n("New Stuff..."));
    item->buttonGo->setEnabled(true);
    QObject::connect(item->buttonGo, SIGNAL(clicked()),
                     this, SLOT(getNewStuff()));

    tableThemes->insertItem((QWidget*)(item));

    item = new ThemeWidget;
    item->iconLabel->setPixmap(KIconLoader::global()->loadIcon("document-open",
                               KIconLoader::NoGroup, KIconLoader::SizeHuge));
    item->setHeaderText(i18n("Open Local Theme"));
    item->setDescriptionText(i18n("Add local theme to the list."));
    item->buttonGo->setProperty("stdItem", 18);
    item->buttonGo->setText(i18nc("Open theme button", "Open..."));
    QObject::connect((QObject*)(item->buttonGo), SIGNAL(clicked()),
                     (QObject*)(this), SLOT(openLocalTheme()));
    tableThemes->insertItem((QWidget*)item);

    dirs = ksd.findDirs("data", QString(kapp->objectName()) + "/themes");
    // Get custom dirs from config here?
    QStringList::Iterator itend(dirs.end());
    for (QStringList::Iterator it = dirs.begin(); it != itend; ++it) {
        QStringList types;
        types << "*.skz" << "*.theme";

        dir.setPath(*it);

        t = dir.entryList(types);
        for (QStringList::Iterator it = t.begin(); it != t.end(); ++it) {
            item = new ThemeWidget(new ThemeFile(dir.filePath(*it)));
            tableThemes->insertItem((QWidget*)item);
            item->buttonGo->setText(i18n("Uninstall"));
            QObject::connect((QObject*)item->buttonGo, SIGNAL(clicked()),
                             (QObject*)this, SLOT(uninstall()));
        }
    }
    t = SuperKarambaSettings::userAddedThemes();
    for (QStringList::Iterator it = t.begin(); it != t.end(); ++it) {
        ThemeFile* file = new ThemeFile(*it);

        if (file->isValid()) {
            item = new ThemeWidget(file);
            tableThemes->insertItem((QWidget*)item);
            item->buttonGo->setText(i18n("Uninstall"));
            QObject::connect((QObject*)item->buttonGo, SIGNAL(clicked()),
                             (QObject*)this, SLOT(uninstall()));
        } else
            delete file;
    }
    tableThemes->setSelected(0);
}
开发者ID:KDE,项目名称:superkaramba,代码行数:68,代码来源:themesdlg.cpp


注:本文中的QDir::setPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。