Пример #1
0
SearchProviderDialog::SearchProviderDialog(SearchProvider *provider, QList<SearchProvider*> &providers, QWidget *parent)
    : KDialog( parent )
    , m_provider(provider)
{
    setModal(true);
    setButtons( Ok | Cancel );

    m_dlg.setupUi(mainWidget());

    m_dlg.leQuery->setMinimumWidth(kapp->fontMetrics().averageCharWidth() * 50);

    connect(m_dlg.leName,      SIGNAL(textChanged(QString)), SLOT(slotChanged()));
    connect(m_dlg.leQuery,     SIGNAL(textChanged(QString)), SLOT(slotChanged()));
    connect(m_dlg.leShortcut,  SIGNAL(textChanged(QString)), SLOT(slotChanged()));
    connect(m_dlg.leShortcut,  SIGNAL(textChanged(QString)), SLOT(shortcutsChanged(QString)));
    connect(m_dlg.pbPaste,     SIGNAL(clicked()),            SLOT(pastePlaceholder()));

    // Data init
    m_providers = providers;
    QStringList charsets = KGlobal::charsets()->availableEncodingNames();
    charsets.prepend(i18nc("@item:inlistbox The default character set", "Default"));
    m_dlg.cbCharset->addItems(charsets);
    if (m_provider)
    {
        setPlainCaption(i18n("Modify Web Shortcut"));
        m_dlg.leName->setText(m_provider->name());
        m_dlg.leQuery->setText(m_provider->query());
        m_dlg.leShortcut->setText(m_provider->keys().join(","));
        m_dlg.cbCharset->setCurrentIndex(m_provider->charset().isEmpty() ? 0 : charsets.indexOf(m_provider->charset()));
        m_dlg.leName->setEnabled(false);
        m_dlg.leQuery->setFocus();
    }
    else
    {
        setPlainCaption(i18n("New Web Shortcut"));
        m_dlg.leName->setFocus();

        //If the clipboard contains a url copy it to the query lineedit
        const QClipboard *clipboard = QApplication::clipboard();
        const QString url = clipboard->text();

        if (!KUrl(url).host().isEmpty())
            m_dlg.leQuery->setText(url);

        enableButton(Ok, false);
    }
}
Пример #2
0
void MainWindow::setCurrentFile(const QString &fileName)
{
    curFile = fileName;
    setWindowFilePath(curFile);
    QSettings settings;
    QStringList files = settings.value("recentFileList").toStringList();
    files.removeAll(fileName);
    files.prepend(fileName);
    while (files.size() > MaxRecentFiles)
        files.removeLast();

    settings.setValue("recentFileList", files);
    foreach (QWidget *widget, QApplication::topLevelWidgets()) {
        MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
        if (mainWin)
            mainWin->updateRecentFileActions();
    }
Пример #3
0
void
Finder::find(const RangeList &selectionRanges, int currentIndex, const QString &text, bool findBackwards)
{
	if(!m_subtitle || !m_subtitle->linesCount())
		return;

	invalidate();

	m_dialog->setOptions(findBackwards ? m_dialog->options() | KFind::FindBackwards : m_dialog->options() & ~KFind::FindBackwards);

	if(!text.isEmpty()) {
		QStringList history = m_dialog->findHistory();
		history.removeAll(text);
		history.prepend(text);
		m_dialog->setFindHistory(history);
	}

	if(m_dialog->exec() != QDialog::Accepted)
		return;

	m_find = new KFind(m_dialog->pattern(), m_dialog->options(), 0);
	m_find->closeFindNextDialog();

	connect(m_find, SIGNAL(highlight(const QString &, int, int)), this, SLOT(onHighlight(const QString &, int, int)));

	m_iterator = new SubtitleIterator(*m_subtitle, m_dialog->options() & KFind::SelectedText ? selectionRanges : Range::full());
	if(m_iterator->index() == SubtitleIterator::Invalid) {
		invalidate();
		return;
	}
	m_iterator->setAutoSync(true);

	connect(m_iterator, SIGNAL(syncronized(int, int, bool)), this, SLOT(onIteratorSynchronized(int, int, bool)));

	if(m_dialog->options() & KFind::FromCursor)
		m_iterator->toIndex(currentIndex < 0 ? 0 : currentIndex);

	m_allSearchedIndex = m_iterator->index();

	m_find->setPattern(m_dialog->pattern());
	m_find->setOptions(m_dialog->options());

	m_instancesFound = false;

	advance();
}
Пример #4
0
QStringList FLUtil::nombreCampos(const QString &tabla)
{
  QStringList res;

  if (FLSqlConnections::database()->managerModules()->shaOfFile(tabla + ".mtd").isEmpty())
    return res;

  FLSqlCursor c(tabla);
  FLTableMetaData *tmd = c.metadata();
  if (!tmd)
    return res;

  res = QStringList::split(',', tmd->fieldsNames());
  res.prepend(QString::number(res.size()));

  return res;
}
Пример #5
0
void Window::openFile()
{
	QString fileName = glWidget->openSheet(tr(""));
	if(fileName == "") return;
	
	QSettings settings("mallard.ini", QSettings::IniFormat, this);

    QStringList files = settings.value("recentFileList").toStringList();
    files.removeAll(fileName);
    files.prepend(fileName);
    while (files.size() > MaxRecentFiles)
        files.removeLast();

    settings.setValue("recentFileList", files);

    updateRecentFileActions();
}
Пример #6
0
// This is equivalent to  line.split( QRegExp("\n(?!\n|$)") ) but much faster
QStringList Quoter::splitLines(const QString &line)
{
    QStringList result;
    int i = line.size();
    while (true) {
        int j = i - 1;
        while (j >= 0 && line.at(j) == QLatin1Char('\n'))
            --j; 
        while (j >= 0 && line.at(j) != QLatin1Char('\n'))
            --j; 
        result.prepend(line.mid(j + 1, i - j - 1));
        if (j < 0)
            break;
        i = j;
    }
    return result;
}
Пример #7
0
const QList<audioDevice> CoreAudioSystem::getDeviceChoices(bool input) {
	QHash<QString, QString> qhDevices = CoreAudioSystem::getDevices(input);
	QList<audioDevice> qlReturn;
	QStringList qlDevices;

	qhDevices.insert(QString(), tr("Default Device"));
	qlDevices = qhDevices.keys();

	const QString &qsDev = input ? g.s.qsCoreAudioInput : g.s.qsCoreAudioOutput;
	if (qlDevices.contains(qsDev)) {
		qlDevices.removeAll(qsDev);
		qlDevices.prepend(qsDev);
	}

	foreach(const QString &qsIdentifier, qlDevices) {
		qlReturn << audioDevice(qhDevices.value(qsIdentifier), qsIdentifier);
	}
Пример #8
0
void ccRecentFiles::addFilePath( const QString &filePath )
{
	QStringList	list = m_settings.value( s_settingKey ).toStringList();
	
	list.removeAll( filePath );
	list.prepend( filePath );
	
	// only save the last ten files
	if ( list.count() > 10 )
	{
		list = list.mid( 0, 10 );
	}
	
	m_settings.setValue( s_settingKey, list );
	
	updateMenu();
}
Пример #9
0
QString QgsApplication::relativePathToAbsolutePath( QString rpath, QString targetPath )
{
  // relative path should always start with ./ or ../
  if ( !rpath.startsWith( "./" ) && !rpath.startsWith( "../" ) )
  {
    return rpath;
  }

#if defined(Q_OS_WIN)
  rpath.replace( "\\", "/" );
  targetPath.replace( "\\", "/" );

  bool uncPath = targetPath.startsWith( "//" );
#endif

  QStringList srcElems = rpath.split( "/", QString::SkipEmptyParts );
  QStringList targetElems = targetPath.split( "/", QString::SkipEmptyParts );

#if defined(Q_OS_WIN)
  if ( uncPath )
  {
    targetElems.insert( 0, "" );
    targetElems.insert( 0, "" );
  }
#endif

  // append source path elements
  targetElems << srcElems;
  targetElems.removeAll( "." );

  // resolve ..
  int pos;
  while (( pos = targetElems.indexOf( ".." ) ) > 0 )
  {
    // remove preceding element and ..
    targetElems.removeAt( pos - 1 );
    targetElems.removeAt( pos - 1 );
  }

#if !defined(Q_OS_WIN)
  // make path absolute
  targetElems.prepend( "" );
#endif

  return targetElems.join( "/" );
}
Пример #10
0
QT_BEGIN_NAMESPACE

/*
    This function looks at two file names and returns the name of the
    infile with a path relative to outfile.

    Examples:

        /tmp/abc, /tmp/bcd -> abc
        xyz/a/bc, xyz/b/ac -> ../a/bc
        /tmp/abc, xyz/klm -> /tmp/abc
 */

static QByteArray combinePath(const char *infile, const char *outfile)
{
    QFileInfo inFileInfo(QDir::current(), QFile::decodeName(infile));
    QFileInfo outFileInfo(QDir::current(), QFile::decodeName(outfile));
    int numCommonComponents = 0;

    QStringList inSplitted = inFileInfo.dir().canonicalPath().split(QLatin1Char('/'));
    QStringList outSplitted = outFileInfo.dir().canonicalPath().split(QLatin1Char('/'));

    while (!inSplitted.isEmpty() && !outSplitted.isEmpty() &&
            inSplitted.first() == outSplitted.first()) {
        inSplitted.removeFirst();
        outSplitted.removeFirst();
        numCommonComponents++;
    }

    if (numCommonComponents < 2)
        /*
          The paths don't have the same drive, or they don't have the
          same root directory. Use an absolute path.
        */
        return QFile::encodeName(inFileInfo.absoluteFilePath());
    /*
       The paths have something in common. Use a path relative to
       the output file.
     */
    while (!outSplitted.isEmpty()) {
        outSplitted.removeFirst();
        inSplitted.prepend(QLatin1String(".."));
    }
    inSplitted.append(inFileInfo.fileName());
    return QFile::encodeName(inSplitted.join(QLatin1String("/")));
}
Пример #11
0
QStringList qc_pathlist()
{
	QStringList list;
	QString path = qc_getenv("PATH");
	if(!path.isEmpty())
	{
#ifdef Q_OS_WIN
		list = path.split(';', QString::SkipEmptyParts);
#else
		list = path.split(':', QString::SkipEmptyParts);
#endif
	}
#ifdef Q_OS_WIN
	list.prepend(".");
#endif
	return list;
}
Пример #12
0
QStringList DecoderRegistry::getSupportedTypes(void)
{
	QStringList types;

	types << GET_FILETYPES(WaveDecoder);
	types << GET_FILETYPES(MP3Decoder);
	types << GET_FILETYPES(VorbisDecoder);
	types << GET_FILETYPES(AACDecoder);
	types << GET_FILETYPES(AC3Decoder);
	types << GET_FILETYPES(FLACDecoder);
	types << GET_FILETYPES(WavPackDecoder);
	types << GET_FILETYPES(MusepackDecoder);
	types << GET_FILETYPES(ShortenDecoder);
	types << GET_FILETYPES(MACDecoder);
	types << GET_FILETYPES(TTADecoder);
	types << GET_FILETYPES(SpeexDecoder);
	types << GET_FILETYPES(ALACDecoder);
	types << GET_FILETYPES(WMADecoder);
	types << GET_FILETYPES(ADPCMDecoder);
	types << GET_FILETYPES(OpusDecoder);
	types << GET_FILETYPES(AvisynthDecoder);

	QStringList extensions;
	extensions << QString(PlaylistImporter::supportedExtensions).split(" ", QString::SkipEmptyParts);
	QRegExp regExp("\\((.+)\\)", Qt::CaseInsensitive);

	for(int i = 0; i < types.count(); i++)
	{
		if(regExp.lastIndexIn(types.at(i)) >= 0)
		{
			extensions << regExp.cap(1).split(" ", QString::SkipEmptyParts);
		}
	}

	if(!extensions.empty())
	{
		extensions.removeDuplicates();
		extensions.sort();
		types.prepend(QString("%1 (%2)").arg(tr("All supported types"), extensions.join(" ")));
	}
	
	types << QString("%1 (%2)").arg(tr("Playlists"), PlaylistImporter::supportedExtensions);
	types << QString("%1 (*.*)").arg(tr("All files"));

	return types;
}
Пример #13
0
void MainWindow::addChild(const QString& imageFileName) {
  if (!imageFileName.isEmpty()) {
    QString canonicalImageFileName =
      QFileInfo(imageFileName).canonicalFilePath();
    for (int i = 0; i < tabWidget->count(); ++i) {
      ChildWidget* child = qobject_cast<ChildWidget*> (tabWidget->widget(i));
      if (canonicalImageFileName == child->canonicalImageFileName()) {
        tabWidget->setCurrentIndex(i);
        return;
      }
    }

    ChildWidget* child = new ChildWidget(this);
    if (child->loadImage(imageFileName)) {
      statusBar()->showMessage(tr("File loaded"), 2000);
      tabWidget->setCurrentIndex(tabWidget->addTab(child,
                                 child->userFriendlyCurrentFile()));
      tabWidget->setTabToolTip(tabWidget->currentIndex(), imageFileName);
      connect(child, SIGNAL(boxChanged()), this, SLOT(updateCommandActions()));
      connect(child, SIGNAL(modifiedChanged()), this, SLOT(updateTabTitle()));
      connect(child, SIGNAL(modifiedChanged()), this, SLOT(updateSaveAction()));
      connect(child, SIGNAL(zoomRatioChanged(qreal)), this,
              SLOT(zoomRatioChanged(qreal)));
      connect(child, SIGNAL(statusBarMessage(QString)), this,
              SLOT(statusBarMessage(QString)));
      connect(child, SIGNAL(drawRectangleChoosen()), this, SLOT(updateCommandActions()));
      child->setZoomStatus();
      // save path of open image file
      QSettings settings(QSettings::IniFormat, QSettings::UserScope,
                         SETTING_ORGANIZATION, SETTING_APPLICATION);
      QString filePath = QFileInfo(imageFileName).absolutePath();
      settings.setValue("last_path", filePath);

      QStringList files = settings.value("recentFileList").toStringList();
      files.removeAll(imageFileName);
      files.prepend(imageFileName);
      while (files.size() > MaxRecentFiles)
        files.removeLast();

      settings.setValue("recentFileList", files);

      foreach(QWidget * widget, QApplication::topLevelWidgets()) {
        MainWindow* mainWin = qobject_cast<MainWindow*>(widget);
        if (mainWin)
          mainWin->updateRecentFileActions();
      }
Пример #14
0
QFileInfoList Zerberus::sfzFiles()
      {
      QFileInfoList l;

      QStringList pl = Ms::preferences.getString(PREF_APP_PATHS_MYSOUNDFONTS).split(";");
      pl.prepend(QFileInfo(QString("%1%2").arg(Ms::mscoreGlobalShare).arg("sound")).absoluteFilePath());

      // append extensions directory
      QStringList extensionsDir = Ms::Extension::getDirectoriesByType(Ms::Extension::sfzsDir);
      pl.append(extensionsDir);

      foreach (const QString& s, pl) {
            QString ss(s);
            if (!s.isEmpty() && s[0] == '~')
                  ss = QDir::homePath() + s.mid(1);
            collectFiles(&l, ss);
            }
Пример #15
0
QStringList Nicookie::firefoxGetProfileList(const QString &profile_ini)
{
    QStringList list;
    QFile profile_file(profile_ini);
    if (!profile_file.exists()) {
        setError(Nicookie::FailedParseProfileError);
        return list;
    }

    QTemporaryFile profile_temp;
    QString profile_temp_path = profile_temp.fileTemplate();
    if (profile_file.copy(profile_temp_path)) {
        setError(Nicookie::FailedParseProfileError);
        return list;
    }

    QSettings profile_settings(profile_temp_path, QSettings::IniFormat);
    if (profile_settings.status() != QSettings::NoError) {
        setError(Nicookie::FailedParseProfileError);
        return list;
    }

    for (auto &group: profile_settings.childGroups()) {
        if (group.startsWith("Profile")) {
            profile_settings.beginGroup(group);
            QString path;
            if (profile_settings.value("IsRelative", 1).toInt() == 1) {
                path = QFileInfo(profile_file).dir().filePath(
                            profile_settings.value("Path").toString());
            } else {
                path = profile_settings.value("Path").toString();
            }
            if (profile_settings.value("Default", 0).toInt() == 1) {
                list.prepend(path);
            } else {
                list.append(path);
            }
            profile_settings.endGroup();
        }
    }

    if (list.isEmpty()) {
        setError(Nicookie::FailedParseProfileError);
    }
    return list;
}
Пример #16
0
void MatcherModel::matchExpression()
{
    beginResetModel();
    m_matches.clear();
    endResetModel();

    QStringList matches;
    for (const QString &entry: m_items) {
        if (entry == m_expression) {
            matches.prepend(entry);
        } else if (entry.startsWith(m_expression)) {
            matches.append(entry);
        }
    }
    beginInsertRows(QModelIndex(), 0, matches.count());
    m_matches = matches;
    endInsertRows();
}
Пример #17
0
const QStringList &
ScriptsManager::mimeTypes()
{
	static QStringList mimeTypes;

	if(mimeTypes.isEmpty()) {
		QHash<QString, Kross::InterpreterInfo *> infos = Kross::Manager::self().interpreterInfos();
		for(QHash<QString, Kross::InterpreterInfo *>::ConstIterator it = infos.begin(), end = infos.end(); it != end; ++it) {
			QStringList intMimeTypes = it.value()->mimeTypes();
			for(QStringList::ConstIterator it = intMimeTypes.begin(), end = intMimeTypes.end(); it != end; ++it)
				mimeTypes << *it;
		}
		if(!mimeTypes.contains("application/javascript") && !mimeTypes.contains("text/javascript") && !mimeTypes.contains("application/x-javascript"))
			mimeTypes.prepend("application/javascript");
	}

	return mimeTypes;
}
Пример #18
0
x509v3ext NewX509::getEkeyUsage()
{
	QStringList cont;
	x509v3ext ext;

	int rows = ekeyUsage->count();
	for (int i=0; i<rows; i++) {
		//QListWidgetItem *li = ekeyUsage->item(i);
		//printf("rows = %d, ekeyUsage = %d, %p\n", rows, i, li);
		if (ekeyUsage->isItemSelected(ekeyUsage->item(i))) {
			cont << QString(OBJ_nid2sn(eku_nid[i]));
		}
	}
	if (ekuCritical->isChecked() && cont.count() > 0)
		cont.prepend("critical");
	ext.create(NID_ext_key_usage, cont.join(", "), &ext_ctx);
	return ext;
}
Пример #19
0
QStringList Configuration::getFileOpenFilters( FileType firstType )
{
    QStringList exts = getFileExtension();
    QStringList filterList;

    for ( int i = 0; i < FileTypeNum && i < exts.length(); i++ ) {
        QString filter = QString::fromLatin1( "%1 (%2)" ).arg( fileTypeToString( i ) ).arg( exts.value(
                             i ).split( "|" ).join( " " ) );

        if ( firstType == i ) {
            filterList.prepend( filter );
        } else {
            filterList.append( filter );
        }
    }

    return filterList;
}
Пример #20
0
void HistoryWindow::addHistory(const QString &str)
{
    QStringList l = CorePlugin::instance()->value("HistorySearch").toString().split(';');
    l.removeAll(str);
    l.prepend(str);

    QString res;
    unsigned i = 0;
    Q_FOREACH(const QString &str, l)
    {
        if (i++ > MAX_HISTORY)
            break;
        if (!res.isEmpty())
            res += ';';
        res += quoteChars(str, ";");
    }
    CorePlugin::instance()->setValue("HistorySearch", res);
}
Пример #21
0
void TIGLViewerWindow::setCurrentFile(const QString &fileName)
{
    setWindowFilePath(fileName);
    currentFile = fileName;

    QSettings settings("DLR SC-VK","TIGLViewer");
    QStringList files = settings.value("recentFileList").toStringList();
    files.removeAll(fileName);
    files.prepend(fileName);
    while (files.size() > MaxRecentFiles) {
        files.removeLast();
    }

    settings.setValue("recentFileList", files);
    settings.setValue("lastFolder", myLastFolder);

    updateRecentFileActions();
}
Пример #22
0
inline void
FileBrowser::urlChanged( const KURL &u )
{
    //the DirOperator's URL has changed

    QString url = u.isLocalFile() ? u.path() : u.prettyURL();

    if( m_medium ){
        //remove the leading mountPoint value
        url.remove( 0, m_medium->mountPoint().length() );
    }

    QStringList urls = m_combo->urls();
    urls.remove( url );
    urls.prepend( url );

    m_combo->setURLs( urls, KURLComboBox::RemoveBottom );
}
Пример #23
0
// Helper to return the icon theme paths from XDG.
QStringList QGenericUnixTheme::xdgIconThemePaths()
{
    QStringList paths;
    // Add home directory first in search path
    const QFileInfo homeIconDir(QDir::homePath() + QStringLiteral("/.icons"));
    if (homeIconDir.isDir())
        paths.prepend(homeIconDir.absoluteFilePath());

    QString xdgDirString = QFile::decodeName(qgetenv("XDG_DATA_DIRS"));
    if (xdgDirString.isEmpty())
        xdgDirString = QLatin1String("/usr/local/share/:/usr/share/");
    foreach (const QString &xdgDir, xdgDirString.split(QLatin1Char(':'))) {
        const QFileInfo xdgIconsDir(xdgDir + QStringLiteral("/icons"));
        if (xdgIconsDir.isDir())
            paths.append(xdgIconsDir.absoluteFilePath());
    }
    return paths;
}
Пример #24
0
QStringList KoDocumentInfo::pages() const
{
    QStringList ret;

    const QObjectList *list = children();
    if ( list )
    {
        QObjectListIt it( *list );
        QObject *obj;
        while ( ( obj = it.current() ) )
        {
            ret.prepend( obj->name() );
            ++it;
        }
    }

    return ret;
}
Пример #25
0
//////////////////////////////////////////////////////////////////
//单文档实现。
void CMainWindow::setCurrentFile(const QString& fileName)
{
	curFile = QFileInfo(fileName).canonicalFilePath();
	isUntitled = false;
	setWindowTitle(curFile + "[*]");	
	textEdit->document()->setModified(false);
	setWindowModified(false);
	
	QSettings settings("709", "SDI example");
	QStringList files = settings.value("recentFiles").toStringList();
	files.removeAll(fileName);
	files.prepend(fileName);
	while (files.size() > MaxRecentFiles)
		files.removeLast();
	settings.setValue("recentFiles", files);

	updateRecentFiles();
}
Пример #26
0
QStringList QStandardPaths::standardLocations(StandardLocation type)
{
    QStringList dirs;

    // type-specific handling goes here

#ifndef Q_OS_WINCE
    {
        wchar_t path[MAX_PATH];
        switch (type) {
        case ConfigLocation: // same as AppLocalDataLocation, on Windows (oversight, but too late to fix it)
        case GenericConfigLocation: // same as GenericDataLocation, on Windows
        case AppDataLocation:
        case AppLocalDataLocation:
        case GenericDataLocation:
            if (SHGetSpecialFolderPath(0, path, clsidForAppDataLocation(type), FALSE)) {
                QString result = convertCharArray(path);
                if (type != GenericDataLocation && type != GenericConfigLocation) {
#ifndef QT_BOOTSTRAPPED
                    if (!QCoreApplication::organizationName().isEmpty())
                        result += QLatin1Char('/') + QCoreApplication::organizationName();
                    if (!QCoreApplication::applicationName().isEmpty())
                        result += QLatin1Char('/') + QCoreApplication::applicationName();
#endif
                }
                dirs.append(result);
#ifndef QT_BOOTSTRAPPED
                if (type != GenericDataLocation) {
                    dirs.append(QCoreApplication::applicationDirPath());
                    dirs.append(QCoreApplication::applicationDirPath() + QLatin1String("/data"));
                }
#endif
            }
            break;
        default:
            break;
        }
    }
#endif

    const QString localDir = writableLocation(type);
    dirs.prepend(localDir);
    return dirs;
}
Пример #27
0
void
Replacer::replace(const RangeList &selectionRanges, int currentIndex, const QString &text)
{
	invalidate();

	if(!m_subtitle || !m_subtitle->linesCount())
		return;

	if(!text.isEmpty()) {
		QStringList history = m_dialog->findHistory();
		history.removeAll(text);
		history.prepend(text);
		m_dialog->setFindHistory(history);
	}

	if(m_dialog->exec() != QDialog::Accepted)
		return;

	m_replace = new KReplace(m_dialog->pattern(), m_dialog->replacement(), m_dialog->options(), 0);

	// Connect findNext signal - called when pressing the button in the dialog
	connect(m_replace, SIGNAL(findNext()), this, SLOT(advance()));

	// Connect signals to code which handles highlighting of found text, and on-the-fly replacement.
	connect(m_replace, SIGNAL(highlight(const QString &, int, int)), this, SLOT(onHighlight(const QString &, int, int)));

	// Connect replace signal - called when doing a replacement
	connect(m_replace, SIGNAL(replace(const QString &, int, int, int)), this, SLOT(onReplace(const QString &, int, int, int)));

	if(m_dialog->options() & KFind::SelectedText) {
		m_iterator = new SubtitleIterator(*m_subtitle, selectionRanges);
		if(m_iterator->index() < 0) // Invalid index means no lines in selectionRanges
			return;
	} else
		m_iterator = new SubtitleIterator(*m_subtitle);

	if(m_dialog->options() & KFind::FromCursor)
		m_iterator->toIndex(currentIndex < 0 ? 0 : currentIndex);

	m_firstIndex = m_iterator->index();
	m_instancesFound = false;

	advance();
}
Пример #28
0
void LPMain::restoreFiles(){
  QString filePath = fsModel->filePath( ui->treeView->currentIndex() );
  qDebug() << " Restore file(s):" << filePath;
  QFileInfo info(filePath);	
  QString destDir = filePath;
	destDir.remove("/.zfs/snapshot/"+ui->label_snapshot->text());
	destDir.chop( filePath.section("/",-1).size()+1 ); //get rid of the filename at the end
	while(!QFile::exists(destDir)){ destDir.chop( destDir.section("/",-1).size() +1); }
  QString newFilePath = destDir+"/"+LPGUtils::generateReversionFileName(filePath, destDir);
  //qDebug() << "Destination:" << newFilePath;
  //Perform the reversion(s)
  QStringList errors;
  if( info.isDir() ){
    //Is a directory
    showWaitBox( QString(tr("Restoring Directory: %1")).arg(newFilePath) );
    errors = LPGUtils::revertDir(filePath, newFilePath);
    hideWaitBox();
    if(!errors.isEmpty()){
      qDebug() << "Failed Reversions:" << errors;
      errors.prepend(tr("File destination(s) that could not be restored:")+"\n");
      showErrorDialog(tr("Reversion Error"), tr("Some files could not be restored from the snapshot."), errors.join("\n") );
    }else{
      qDebug() << "Reversion successful";	    
      QMessageBox::information(this,tr("Restore Successful"),QString(tr("The following directory was succesfully restored: %1")).arg(newFilePath) );
    }
  }else{
    //Just a single file
    showWaitBox( QString(tr("Restoring file: %1")).arg(newFilePath) );
    bool ok = LPGUtils::revertFile(filePath, newFilePath);
    hideWaitBox();
    if( !ok ){
      qDebug() << "Failed Reversion:" << newFilePath;
      errors << QString(tr("Snapshot file: %1")).arg(filePath);
      errors << QString(tr("Destination: %1")).arg(newFilePath);
      errors << tr("Please check that the destination directory exists and is writable");
      showErrorDialog(tr("Reversion Error"), tr("The file could not be restored from the snapshot."), errors.join("\n") );
    }else{
      qDebug() << "Reversion successful";
      QMessageBox::information(this,tr("Restore Successful"),QString(tr("The following file was succesfully restored: %1")).arg(newFilePath) );
    }
  }	  
	
}
Пример #29
0
void AnalyseForm::blacklistSelected(QAction * action)
{
    ExceptionBundle * bundle = page->exceptionBundleById(action->data().toInt());
    ExceptionGroup * group;
    if (current_sf->isDir())
        group = bundle->groupByType(ExceptionGroup::FolderBlacklist);
    else
        group = bundle->groupByType(ExceptionGroup::FileBlacklist);

    QStringList path = relativePath(current_sf);
    path.prepend(page->foldersObject()->first()->path());

    group->addItem(path.join("/"));

    if (page->exceptionBundleChecked(bundle->index())) {
        delete current_sf;
        delete ui->tree->selectedItems().first();
    }
}
Пример #30
0
/**
 * Program entry point.
 *
 * @param argc amount of command line arguments
 * @param argv command line arguments
 * @return @c 0 on successful exit
 */
int main(int argc, char** argv)
{
	QApplication app(argc, argv);
	app.setApplicationName("Peg-E");
	app.setApplicationVersion(VERSIONSTR);
	app.setApplicationDisplayName(Window::tr("Peg-E"));
	app.setOrganizationDomain("gottcode.org");
	app.setOrganizationName("GottCode");
#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
	app.setWindowIcon(QIcon::fromTheme("peg-e", QIcon(":/peg-e.png")));
#endif
	app.setAttribute(Qt::AA_DontShowIconsInMenus, true);
	app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);

	LocaleDialog::loadTranslator("pege_");

	// Set location of fallback icons
	{
		QString appdir = app.applicationDirPath();
		QString datadir;
#if defined(Q_OS_MAC)
		datadir = appdir + "/../Resources";
#elif defined(Q_OS_UNIX)
		datadir = appdir + "/../share/peg-e";
#else
		datadir = appdir;
#endif

		QStringList paths = QIcon::themeSearchPaths();
		paths.prepend(datadir + "/icons");
		QIcon::setThemeSearchPaths(paths);
	}

	// Set up icons
	if (QIcon::themeName().isEmpty()) {
		QIcon::setThemeName("hicolor");
	}

	Window window;
	window.show();

	return app.exec();
}