QList<int> QToolBarAreaLayout::indexOf(QWidget *toolBar) const
{
    QList<int> result;

    bool found = false;

    for (int i = 0; i < QInternal::DockCount; ++i) {
        const QToolBarAreaLayoutInfo &dock = docks[i];

        for (int j = 0; j < dock.lines.count(); ++j) {
            const QToolBarAreaLayoutLine &line = dock.lines.at(j);

            for (int k = 0; k < line.toolBarItems.count(); ++k) {
                const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k);
                if (!item.gap && item.widgetItem->widget() == toolBar) {
                    found = true;
                    result.prepend(k);
                    break;
                }
            }

            if (found) {
                result.prepend(j);
                break;
            }
        }

        if (found) {
            result.prepend(i);
            break;
        }
    }

    return result;
}
Example #2
0
/*!
    \since 4.5
    Calls the method \a method on this interface and passes the parameters to this function to the
    method.

    The parameters to \c call are passed on to the remote function via D-Bus as input
    arguments. The returned QDBusPendingCall object can be used to find out information about
    the reply.

    This function can be used with up to 8 parameters, passed in arguments \a arg1, \a arg2,
    \a arg3, \a arg4, \a arg5, \a arg6, \a arg7 and \a arg8. If you need more than 8
    parameters or if you have a variable number of parameters to be passed, use
    asyncCallWithArgumentList().

    It can be used the following way:

    \snippet code/src_qdbus_qdbusabstractinterface.cpp 1

    This example illustrates function calling with 0, 1 and 2 parameters and illustrates different
    parameter types passed in each (the first call to \c "ProcessWorkUnicode" will contain one
    Unicode string, the second call to \c "ProcessWork" will contain one string and one byte array).
*/
QDBusPendingCall QDBusAbstractInterface::asyncCall(const QString &method, const QVariant &arg1,
        const QVariant &arg2,
        const QVariant &arg3,
        const QVariant &arg4,
        const QVariant &arg5,
        const QVariant &arg6,
        const QVariant &arg7,
        const QVariant &arg8)
{
    QList<QVariant> argList;
    int count = 0 + arg1.isValid() + arg2.isValid() + arg3.isValid() + arg4.isValid() +
                arg5.isValid() + arg6.isValid() + arg7.isValid() + arg8.isValid();

    switch (count) {
    case 8:
        argList.prepend(arg8);
    case 7:
        argList.prepend(arg7);
    case 6:
        argList.prepend(arg6);
    case 5:
        argList.prepend(arg5);
    case 4:
        argList.prepend(arg4);
    case 3:
        argList.prepend(arg3);
    case 2:
        argList.prepend(arg2);
    case 1:
        argList.prepend(arg1);
    }

    return asyncCallWithArgumentList(method, argList);
}
void QgsMilXLibrary::itemClicked( const QModelIndex &index )
{

  QModelIndex sourceIndex = mFilterProxyModel->mapToSource( index );
  QList<QModelIndex> indexStack;
  indexStack.prepend( sourceIndex );
  while ( sourceIndex.parent().isValid() )
  {
    sourceIndex = sourceIndex.parent();
    indexStack.prepend( sourceIndex );
  }

  QStandardItem* item = mGalleryModel->itemFromIndex( indexStack.front() );
  if ( item )
  {
    for ( int i = 1, n = indexStack.size(); i < n; ++i )
    {
      item = item->child( indexStack[i].row() );
    }

    QgsMilxSymbolTemplate symbolTemplate;
    symbolTemplate.symbolXml = item->data( SymbolXmlRole ).toString();
    if ( symbolTemplate.symbolXml.isEmpty() )
    {
      return;
    }
    hide();
    if ( symbolTemplate.symbolXml == "<custom>" )
    {
      MilXClient::SymbolDesc desc;
      WId wid = mIface->mapCanvas()->winId();
      if ( !MilXClient::createSymbol( symbolTemplate.symbolXml, desc, wid ) )
      {
        return;
      }
      symbolTemplate.symbolMilitaryName = desc.militaryName;
      symbolTemplate.minNPoints = desc.minNumPoints;
      symbolTemplate.hasVariablePoints = desc.hasVariablePoints;
      symbolTemplate.pixmap = QPixmap::fromImage( desc.icon ).scaled( 32, 32, Qt::KeepAspectRatio );
    }
    else
    {
      symbolTemplate.symbolMilitaryName = item->data( SymbolMilitaryNameRole ).toString();
      symbolTemplate.minNPoints = item->data( SymbolPointCountRole ).toInt();
      symbolTemplate.hasVariablePoints = item->data( SymbolVariablePointsRole ).toInt();
      symbolTemplate.pixmap = item->icon().pixmap( item->icon().actualSize( QSize( 32, 32 ) ) );
    }
    emit symbolSelected( symbolTemplate );
  }
}
Example #4
0
void
LastFmUserSettings::addRecentStation( const Station& station )
{
    MyQSettings s( this );

    QList<Station> stations = recentStations();

    // remove duplicates
    for ( int i = 0; i < stations.count(); ++i )
        if ( stations[i].url() == station.url() )
            stations.removeAt( i-- );

    stations.prepend( station );

    s.remove( "RecentStations" );

    s.beginGroup( "RecentStations" );
    int j = stations.count();
    while (j--)
        s.setValue( QString::number( j ), stations[j].url() );
    s.endGroup();

    s.setValue( "StationNames/" + station.url(), station.name() );
    s.sync();

    emit userChanged( username() );
    emit historyChanged();
}
	void ContactDropFilter::HandleImageDropped (const QImage& image, const QUrl& url)
	{
		QStringList choiceItems
		{
			tr ("Send directly in chat")
		};

		QList<std::function<void ()>> functions
		{
			[this, &image] { SendInChat (image, EntryId_, ChatTab_); }
		};

		if (url.scheme () != "file")
		{
			choiceItems << tr ("Send link");
			functions.append ([this, url] { SendLink (url, EntryId_, ChatTab_); });
		}
		else
		{
			choiceItems.prepend (tr ("Send as file"));
			functions.prepend ([this, &url]
				{
					Core::Instance ().GetTransferJobManager ()->
							OfferURLs (GetEntry<ICLEntry> (EntryId_), { url });
				});

			CollectDataFilters (choiceItems, functions, image);
		}

		PerformChoice (choiceItems, functions);
	}
Example #6
0
File: run.cpp Project: trtikm/E2
void run()
{
    TMPROF_BLOCK();

    int argc = 1;
    char* argv[] = { "" };
    QGuiApplication app(argc, argv);

    QScreen *screen = QGuiApplication::primaryScreen();
    QRect screenGeometry = screen->availableGeometry();
    QPoint center = QPoint(screenGeometry.center().x(), screenGeometry.top() + 80);
    QSize windowSize(400, 320);
    int delta = 40;

    QList<QWindow *> windows;
    xqtgl::window *windowA = new xqtgl::window(&init,&step,&draw,&fini);
    windowA->setGeometry(QRect(center, windowSize).translated(-windowSize.width() - delta / 2, 0));
    windowA->setTitle(QStringLiteral("Window"));
    windowA->setVisible(true);
    windows.prepend(windowA);

    app.exec();

    qDeleteAll(windows);

}
Example #7
0
QList<TextShaper::TextRun> TextShaper::itemizeScripts(const QList<TextRun> &runs)
{
	QList<TextRun> newRuns;
	ScriptRun scriptrun((const UChar*) m_text.utf16(), m_text.length());

	foreach (TextRun run, runs)
	{
		int start = run.start;
		QList<TextRun> subRuns;

		while (scriptrun.next())
		{
			if (scriptrun.getScriptStart() <= start && scriptrun.getScriptEnd() > start)
				break;
		}

		while (start < run.start + run.len)
		{
			int end = qMin(scriptrun.getScriptEnd(), run.start + run.len);
			UScriptCode script = scriptrun.getScriptCode();
			if (run.dir == UBIDI_RTL)
				subRuns.prepend(TextRun(start, end - start, run.dir, script));
			else
				subRuns.append(TextRun(start, end - start, run.dir, script));

			start = end;
			scriptrun.next();
		}

		scriptrun.reset();
		newRuns.append(subRuns);
	}
Example #8
0
void SearchDialog::toggleItems(bool enabled)
{
	QCheckBox *checkBox = qobject_cast<QCheckBox*>(sender());
	for (QListView *list : this->findChildren<QListView*>()) {
		QStandardItemModel *m = qobject_cast<QStandardItemModel*>(list->model());
		// Hiding / restoring items has to be done in 2-steps
		// First step is for finding items that are about to be moved
		// Second step is for iterating backward on marked items -> you cannot remove items on a single for loop
		if (enabled) {
			// Restore hidden items for every list
			QList<QStandardItem*> items = _hiddenItems.value(list);
			QList<int> indexes;
			for (int i = 0; i < items.size(); i++) {
				QStandardItem *item = items.at(i);
				// Extract only matching items
				if (item->data(AbstractSearchDialog::DT_Origin) == checkBox->text()) {
					indexes.prepend(i);
				}
			}

			// Moving back from hidden to visible
			for (int i = 0; i < indexes.size(); i++) {
				QStandardItem *item = items.takeAt(indexes.at(i));
				m->appendRow(item);
			}

			// Replace existing values with potentially empty list
			_hiddenItems.insert(list, items);
			m->sort(0);
		} else {
			// Hide items for every list
			QStandardItemModel *m = qobject_cast<QStandardItemModel*>(list->model());
			QList<QStandardItem*> items;
			QList<QPersistentModelIndex> indexes;
			for (int i = 0; i < m->rowCount(); i++) {
				QStandardItem *item = m->item(i, 0);
				if (item->data(AbstractSearchDialog::DT_Origin).toString() == checkBox->text()) {
					indexes << m->index(i, 0);
					// Default copy-constructor is protected!
					QStandardItem *copy = new QStandardItem(item->text());
					copy->setData(checkBox->text(), AbstractSearchDialog::DT_Origin);
					copy->setIcon(item->icon());
					items.append(copy);
				}
			}

			for (const QPersistentModelIndex &i : indexes) {
				m->removeRow(i.row());
			}

			// Finally, hide selected items
			if (!items.isEmpty()) {
				QList<QStandardItem*> hItems = _hiddenItems.value(list);
				hItems.append(items);
				_hiddenItems.insert(list, hItems);
			}
		}
	}
}
void applistModel::Search()
{
    LS("applistModel::Search =>>");
    QList<AppEntry> results;
    QString s = m_searchString;

    if(m_appslist != NULL  || m_searchString.isEmpty())
        {
        int rank1results = 0;
        for(int i=0; i < m_appslist->count() ; i++)
            {
            QString appname = m_appslist->at(i).caption;
            if(appname.startsWith(s, Qt::CaseInsensitive))
                {
                AppEntry p = m_appslist->at(i);
                p.iscontact = false;
                if(rank1results <= APPSMODELQUOTA)
                    {
                    rank1results++;
                    p.rank = 1;
                    }
                else
                    {
                    p.rank = 2;
                    }

                results.prepend(p);
                }
            else if(appname.contains(s, Qt::CaseInsensitive))
                {
                AppEntry p = m_appslist->at(i);
                p.iscontact = false;
                p.rank = 3;
                results.append(p);
                }
            else
                {//ignore
                }
            }
        }

    //sort and trim the results before sending.
    qSort(results.begin(), results.end(), appentrylessthan2);

    while(results.count() > MAXRESULTS)
        results.removeLast();

//    for(int j=0;j<results.count();j++)
//        {
//        LS(results[j].caption);
//        LS(results[j].rank);
//        }

    emit HandleSearchResults(s, results, 0, false);
    LS("applistModel::Search << "<<QString::number(results.count()));
}
Example #10
0
void LimitTest::testLimits(QCoreApplication &a) {
	QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance();
	if (QLatin1String(ed->metaObject()->className()) != QLatin1String("QEventDispatcherGlib"))
		qWarning("Not running with glib. While you may be able to open more descriptors, sockets above %d will not work", FD_SETSIZE);
	qWarning("Running descriptor test.");
	int count;
	QList<QFile *> ql;
	for (count=0;count < 524288; ++count) {
		QFile *qf = new QFile(a.applicationFilePath());
		if (qf->open(QIODevice::ReadOnly))
			ql.prepend(qf);
		else
			break;
		if ((count & 1023) == 0)
			qWarning("%d descriptors...", count);
	}
	foreach(QFile *qf, ql)
		delete qf;
	ql.clear();
	qCritical("Managed to open %d descriptors", count);

	qm = new QMutex();
	qw = new QWaitCondition();
	qstartw = new QWaitCondition();

	int fdcount = count / 8;
	if (sizeof(void *) < 8)
		if (fdcount > 1024)
			fdcount = 1024;

	QList<LimitTest *> qtl;
	for (count=0;count < fdcount; ++count) {
		LimitTest *t = new LimitTest();
		t->tid = count;
		qtl << t;
		qm->lock();
		t->start();
		qstartw->wait(qm);
		qm->unlock();
		if (! t->isRunning())
			break;
		if ((count & 511) == 0)
			qWarning("%d threads...", count);
	}
	qm->lock();
	qw->wakeAll();
	qm->unlock();

	foreach(LimitTest *qt, qtl) {
		if (! qt->wait(1000)) {
			qWarning("Thread %d failed to terminate...", qt->tid);
			qt->terminate();
		}
	}
	qFatal("Managed to spawn %d threads", count);
}
Example #11
0
void NavigationWidget::restoreSettings(QSettings *settings)
{
    int version = settings->value("Navigation/Version", 1).toInt();
    QStringList views = settings->value("Navigation/Views").toStringList();

    bool restoreSplitterState = true;
    if (version == 1) {
        if (views.isEmpty())
            views += "Projects";
        if (!views.contains("Open Documents")) {
            views += "Open Documents";
            restoreSplitterState = false;
        }
        settings->setValue("Navigation/Version", 2);
    }

    for (int i=0; i<views.count()-1; ++i) {
        insertSubItem(0);
    }
    for (int i=0; i<views.count(); ++i) {
        const QString &view = views.at(i);
        NavigationSubWidget *nsw = m_subWidgets.at(i);
        nsw->setFactory(view);
    }

    if (settings->contains("Navigation/Visible")) {
        setShown(settings->value("Navigation/Visible").toBool());
    } else {
        setShown(true);
    }

    if (restoreSplitterState && settings->contains("Navigation/VerticalPosition")) {
        restoreState(settings->value("Navigation/VerticalPosition").toByteArray());
    } else {
        QList<int> sizes;
        sizes += 256;
        for (int i = views.size()-1; i > 0; --i)
            sizes.prepend(512);
        setSizes(sizes);
    }

    if (settings->contains("Navigation/Width")) {
        m_width = settings->value("Navigation/Width").toInt();
        if (!m_width)
            m_width = 240;
    } else {
        m_width = 240; //pixel
    }
    // Apply
    if (NavigationWidgetPlaceHolder::m_current) {
        NavigationWidgetPlaceHolder::m_current->applyStoredSize(m_width);
    }

    for (int i=0; i<m_subWidgets.count(); ++i)
        m_subWidgets.at(i)->restoreSettings(i);
}
Example #12
0
QList<unsigned int> GumboInterface::get_path_to_node(GumboNode* node) 
{
  QList<unsigned int> apath = QList<unsigned int>();
  GumboNode* anode = node;
  while (anode && !((anode->type == GUMBO_NODE_ELEMENT) && (anode->v.element.tag == GUMBO_TAG_HTML))) {
      apath.prepend(anode->index_within_parent);
      anode = anode->parent;
  }
  return apath;
}
static QList<QByteArray> fullIdForSymbol(Symbol *symbol)
{
    QList<QByteArray> uid;
    Symbol *current = symbol;
    do {
        uid.prepend(idForSymbol(current));
        current = current->enclosingScope();
    } while (current);
    return uid;
}
Example #14
0
QList< Item* > VListCF::extractSingleItems()
{
	QList< Item* > result;

	for (int i = items_.size() - 1; i>=0; --i)
	{
		SequentialLayout* seq = dynamic_cast<SequentialLayout*> (items_[i]);
		if (seq)
		{
			for (int k = seq->length()-1; k>=0; --k) result.prepend(seq->at<Item>(k));
			seq->clear(false);
			SAFE_DELETE_ITEM(seq);
		}
		else result.prepend(items_[i]);
	}

	items_.clear();
	return result;
}
Example #15
0
QPixmap BitmapFactoryInst::pixmap(const char* name) const
{
    if (!name || *name == '\0')
        return QPixmap(px);

    // as very first test check whether the pixmap is in the cache
    QMap<std::string, QPixmap>::ConstIterator it = d->xpmCache.find(name);
    if (it != d->xpmCache.end())
        return it.value();

    // now try to find it in the built-in XPM
    QPixmap icon;
    QMap<std::string,const char**>::ConstIterator It = d->xpmMap.find(name);
    if (It != d->xpmMap.end())
        icon = QPixmap(It.value());

    // Try whether an absolute path is given
    QString fn = QString::fromUtf8(name);
    if (icon.isNull())
        loadPixmap(fn, icon);

    // try to find it in the given directories
    if (icon.isNull()) {
        bool found = false;
        QList<QByteArray> formats = QImageReader::supportedImageFormats();
        formats.prepend("SVG"); // check first for SVG to use special import mechanism
        for (QStringList::ConstIterator pt = d->paths.begin(); pt != d->paths.end() && !found; ++pt) {
            QDir d(*pt);
            QString fileName = d.filePath(fn);
            if (loadPixmap(fileName, icon)) {
                found = true;
                break;
            }
            else {
                // Go through supported file formats
                for (QList<QByteArray>::iterator fm = formats.begin(); fm != formats.end(); ++fm) {
                    QString path = QString::fromAscii("%1.%2").arg(fileName).
                        arg(QString::fromAscii((*fm).toLower().constData()));
                    if (loadPixmap(path, icon)) {
                        found = true;
                        break;
                    }
                }
            }
        }
    }

    if (!icon.isNull()) {
        d->xpmCache[name] = icon;
        return icon;
    }

    Base::Console().Warning("Cannot find icon: %s\n", name);
    return QPixmap(px);
}
void TrackerControls::loadSettings()
{
	ui.cameraName->clear();
	QList<QString> names = get_camera_names();
	names.prepend("Any available");
	ui.cameraName->addItems(names);
	QSettings settings("opentrack");
	QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
	QSettings iniFile( currentFile, QSettings::IniFormat );
	iniFile.beginGroup( "aruco-Tracker" );
	ui.cameraName->setCurrentIndex(iniFile.value("camera-index", -1).toInt() + 1);
    ui.cameraFOV->setValue(iniFile.value("fov", 56).toFloat());
	int fps;
	switch (iniFile.value("fps", 0).toInt())
	{
	default:
	case 0:
		fps = 0;
		break;
	case 30:
		fps = 1;
		break;
	case 60:
		fps = 2;
		break;
	case 120:
		fps = 3;
		break;
	}
	ui.cameraFPS->setCurrentIndex(fps);
	ui.rx->setCheckState(iniFile.value("enable-rx", true).toBool() ? Qt::Checked : Qt::Unchecked);
	ui.ry->setCheckState(iniFile.value("enable-ry", true).toBool() ? Qt::Checked : Qt::Unchecked);
	ui.rz->setCheckState(iniFile.value("enable-rz", true).toBool() ? Qt::Checked : Qt::Unchecked);
	ui.tx->setCheckState(iniFile.value("enable-tx", true).toBool() ? Qt::Checked : Qt::Unchecked);
	ui.ty->setCheckState(iniFile.value("enable-ty", true).toBool() ? Qt::Checked : Qt::Unchecked);
	ui.tz->setCheckState(iniFile.value("enable-tz", true).toBool() ? Qt::Checked : Qt::Unchecked);
    ui.resolution->setCurrentIndex(iniFile.value("resolution", 0).toInt());

    QDoubleSpinBox* headpos[] = {
        ui.cx,
        ui.cy,
        ui.cz
    };

    for (int i = 0; i < 3; i++)
    {
        headpos[i]->setValue(iniFile.value(QString("headpos-%1").arg(i)).toDouble());
    }

    ui.pitch_deg->setValue(iniFile.value("pitch", 0).toDouble());

	iniFile.endGroup();
	settingsDirty = false;
}
Example #17
0
    ZVariant prepend(const QList<ZVariant> &args)
    {
        if (args.count() > 1) {
            QList<ZVariant> list = args.first().toList();

            list.prepend(args.at(1));
            args.first().depthCopyAssign(list);
        }

        return args.first();
    }
Example #18
0
QList<QPersistentModelIndex>
BookmarkModel::indexListFor(const QString &label) const
{
    QList<QPersistentModelIndex> hits;
    const QModelIndexList &list = collectItems(QModelIndex());
    foreach(const QModelIndex &index, list) {
        if (index.data().toString().contains(label, Qt::CaseInsensitive))
            hits.prepend(index);    // list is reverse sorted
    }
    return hits;
}
Example #19
0
void Widget::on_treeWidget_clicked(const QModelIndex &index)
{
    QList<int> indexy;
    indexy.append(index.row());

    for(QModelIndex parentIndex=index.parent(); parentIndex.row() >=0; parentIndex=parentIndex.parent()){
        indexy.prepend(parentIndex.row());
    }

    while (indexy.size()<4) {
        indexy.append(-1);
    }

    switch(indexy.at(1)){
    case 0: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter1.html")); break;}
    case 1: {
        switch(indexy.at(2)){
        case 0: {
            switch(indexy.at(3)){
            case 0: {    myWeb->load(QUrl(filePath+"/html/sniffer_chapter2tty.html#tty_set")); break;}
            case 1: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter2tty.html#hayes_set")); break;}
            case 2: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter2tty.html#ethy_set")); break;}
            default: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter2tty.html#connection-section")); break;}
            }
            break;}
        case 1: {
            switch(indexy.at(3)){
            case 0: {    myWeb->load(QUrl(filePath+"/html/sniffer_chapter2param.html#param")); break;}
            case 1: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter2param.html#modes")); break;}
            default: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter2param.html")); break;}
            }
            break;}
        case 2: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter2term.html")); break;}
        default: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter2tty.html")); break;}

        }

        break;}

    case 2: {
        switch(indexy.at(2)){
        case 0: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter3file.html#file")); break;}
        case 1: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter3view.html")); break;}
        case 2: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter3adv.html")); break;}
        case 3: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter3switch.html")); break;}
        case 4: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter3sett.html")); break;}
        case 5: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter3help.html")); break;}
        default: { myWeb->load(QUrl(filePath+"/html/sniffer_chapter3file.html")); break;}
        }

        break;}
    default: { myWeb->load(QUrl(filePath+"/html/sniffer_index.html")); break;}
    }
}
 void visit(QList<QGraphicsItem *> *items)
 {
     for (int i = 0; i < items->size(); ++i) {
         QGraphicsItem *item = items->at(i);
         if (onlyTopLevelItems && item->d_ptr->parent)
             item = item->topLevelItem();
         if (!item->d_func()->itemDiscovered && item->d_ptr->visible) {
             item->d_func()->itemDiscovered = 1;
             foundItems->prepend(item);
         }
     }
 }
Example #21
0
void MultiplexerLogger::replaceLoggersPlusConsole(
    Log::Severity consoleLoggerSeverity, QList<Logger*> newLoggers,
    bool takeOwnership) {
  QFile *console = new QFile;
  console->open(1, QIODevice::WriteOnly|QIODevice::Unbuffered);
  FileLogger *consoleLogger = new FileLogger(console, consoleLoggerSeverity);
  newLoggers.prepend(consoleLogger);
  QMutexLocker locker(&_loggersMutex);
  // own console logger regardless taking ownership of other loggers
  _ownedLoggers.insert(consoleLogger);
  doReplaceLoggers(newLoggers, takeOwnership);
}
Example #22
0
void FocusChain::makeFirstInChain(Client *client, QList< Client * >& chain)
{
    chain.removeAll(client);
    if (client->isMinimized()) { // add it before the first minimized ...
        for (int i = chain.count()-1; i >= 0; --i) {
            if (chain.at(i)->isMinimized()) {
                chain.insert(i+1, client);
                return;
            }
        }
        chain.prepend(client); // ... or at end of chain
    } else {
        chain.append(client);
    }
}
//this functions returns the path to the possible gapindex for the position pos
QList<int> QToolBarAreaLayout::gapIndex(const QPoint &pos) const
{
    Qt::LayoutDirection dir = mainWindow->layoutDirection();
    int minDistance = 80; // when a dock area is empty, how "wide" is it?
    QList<int> ret; //return value
    for (int i = 0; i < QInternal::DockCount; ++i) {
        QPoint p = pos;
        if (docks[i].o == Qt::Horizontal)
            p = QStyle::visualPos(dir, docks[i].rect, p);
        QList<int> result = docks[i].gapIndex(p, &minDistance);
        if (!result.isEmpty()) {
            result.prepend(i);
            ret = result;
        }
    }

    return ret;
}
static void prepare(KoShape *s, QMap<KoShape*, QList<KoShape*> > &newOrder, KoShapeManager *manager, KoShapeReorderCommand::MoveShapeType move)
{
    KoShapeContainer *parent = s->parent();
    QMap<KoShape*, QList<KoShape*> >::iterator it(newOrder.find(parent));
    if (it == newOrder.end()) {
        QList<KoShape*> children;
        if (parent != 0) {
            children = parent->shapes();
        }
        else {
            // get all toplevel shapes
            children = manager->topLevelShapes();
        }
        qSort(children.begin(), children.end(), KoShape::compareShapeZIndex);
        // the append and prepend are needed so that the raise/lower of all shapes works as expected.
        children.append(0);
        children.prepend(0);
        it = newOrder.insert(parent, children);
    }
    QList<KoShape *> & shapes(newOrder[parent]);
    int index = shapes.indexOf(s);
    if (index != -1) {
        shapes.removeAt(index);
        switch (move) {
        case KoShapeReorderCommand::BringToFront:
            index = shapes.size();
            break;
        case KoShapeReorderCommand::RaiseShape:
            if (index < shapes.size()) {
                ++index;
            }
            break;
        case KoShapeReorderCommand::LowerShape:
            if (index > 0) {
                --index;
            }
            break;
        case KoShapeReorderCommand::SendToBack:
            index = 0;
            break;
        }
        shapes.insert(index,s);
    }
}
Example #25
0
QList<OptionalProperty> KisNodeDelegate::Private::rightmostProperties(const KisBaseNode::PropertyList &props) const
{
    QList<OptionalProperty> list;
    QList<OptionalProperty> prependList;
    list << OptionalProperty(0);
    list << OptionalProperty(0);
    list << OptionalProperty(0);

    KisBaseNode::PropertyList::const_iterator it = props.constBegin();
    KisBaseNode::PropertyList::const_iterator end = props.constEnd();
    for (; it != end; ++it) {
        if (!it->isMutable) continue;

        if (it->id == KisLayerPropertiesIcons::visible.id()) {
            // noop...
        } else if (it->id == KisLayerPropertiesIcons::locked.id()) {
            list[0] = OptionalProperty(&(*it));
        } else if (it->id == KisLayerPropertiesIcons::inheritAlpha.id()) {
            list[1] = OptionalProperty(&(*it));
        } else if (it->id == KisLayerPropertiesIcons::alphaLocked.id()) {
            list[2] = OptionalProperty(&(*it));
        } else {
            prependList.prepend(OptionalProperty(&(*it)));
        }
    }

    {
        QMutableListIterator<OptionalProperty> i(prependList);
        i.toBack();
        while (i.hasPrevious()) {
            OptionalProperty val = i.previous();

            int emptyIndex = list.lastIndexOf(0);
            if (emptyIndex < 0) break;

            list[emptyIndex] = val;
            i.remove();
        }
    }

    return prependList + list;
}
void GGstLaunchMediaManager::BuildLaunchVideoCommand(QList<QByteArray> &balVideoCmdLine, const int iVideoWidth, const int iVideoHeight, const int iVideoTopLeftX, const int iVideoTopLeftY, const QString &strVideoFile)
{
	//"filesrc location=%1 ! qtdemux name=demux demux.video_00 ! queue ! %2 ! 
	//omapsink x=%3 y=%4 overlayWidth=%5 overlayHeight=%6 sync=true max-lateness=%7 rotation=%8
	//demux.audio_00 ! queue max-size-buffers=%9 max-size-time=0 max-size-bytes=0 ! %10 ! alsasink"
	
	balVideoCmdLine = m_strVideoGstPipeline.arg(m_strCurrentVideoFilePath+strVideoFile)
								.arg(m_strVideoVideoDecoderGstElement)
								.arg(iVideoTopLeftX).arg(iVideoTopLeftY)
								.arg(iVideoWidth).arg(iVideoHeight)
								.arg(m_strVideoLateness)
								.arg(m_iVideoRotation)
								.arg(m_strVideoMaxBufs)								
								.arg(m_strVideoAudioDecoderGstElement)
									  .toLocal8Bit()
									  .split(' ');

	balVideoCmdLine.prepend(m_strVideoAppCommand.toLocal8Bit());

}
static QList<qint64> findSnapshotIdsRecursively(QScriptDebuggerLocalsModelNode *root)
{
    QList<qint64> result;
    if (root->snapshotId == -1) {
        Q_ASSERT(root->children.isEmpty());
        return result;
    }
    QList<QScriptDebuggerLocalsModelNode*> nodeStack;
    nodeStack.append(root);
    while (!nodeStack.isEmpty()) {
        QScriptDebuggerLocalsModelNode *node = nodeStack.takeFirst();
        result.append(node->snapshotId);
        for (int i = 0; i < node->children.count(); ++i) {
            QScriptDebuggerLocalsModelNode *child = node->children.at(i);
            if (child->snapshotId != -1)
                nodeStack.prepend(child);
        }
    }
    return result;
}
QList<qint64> TProcessInfo::allConcurrentPids()
{
    QList<qint64> ret;
    struct kinfo_proc *kp;
    size_t bufSize = 0;
    int mib[3] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL };

    if (sysctl(mib, 3, NULL, &bufSize, NULL, 0) == 0) {
        kp = (struct kinfo_proc *) new char[bufSize];
        if (sysctl(mib, 3, kp, &bufSize, NULL, 0) == 0) {
            for (size_t i = 0; i < (bufSize / sizeof(struct kinfo_proc)); ++i) {
                qint64 pid = kp[i].kp_proc.p_pid;
                if (pid > 0)
                    ret.prepend(pid);
            }
        }
        delete[] kp;
    }

    qSort(ret.begin(), ret.end());  // Sorts the items
    return ret;
}
Example #29
0
QMimeData *QmlOutlineModel::mimeData(const QModelIndexList &indexes) const
{
    if (indexes.count() <= 0)
        return 0;
    QStringList types = mimeTypes();
    QMimeData *data = new QMimeData();
    QString format = types.at(0);
    QByteArray encoded;
    QDataStream stream(&encoded, QIODevice::WriteOnly);
    stream << indexes.size();

    for (int i = 0; i < indexes.size(); ++i) {
        QModelIndex index = indexes.at(i);

        QList<int> rowPath;
        for (QModelIndex i = index; i.isValid(); i = i.parent()) {
            rowPath.prepend(i.row());
        }

        stream << rowPath;
    }
    data->setData(format, encoded);
    return data;
}
Example #30
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    const bool multipleWindows = false;

    QScreen *screen = QGuiApplication::primaryScreen();

    QRect screenGeometry = screen->availableGeometry();

    QSurfaceFormat format;
    format.setDepthBufferSize(16);
    format.setSamples(4);

    QPoint center = QPoint(screenGeometry.center().x(), screenGeometry.top() + 80);
    QSize windowSize(400, 320);
    int delta = 40;

    QList<QWindow *> windows;
    QSharedPointer<Renderer> rendererA(new Renderer(format));

    HelloWindow *windowA = new HelloWindow(rendererA);
    windowA->setGeometry(QRect(center, windowSize).translated(-windowSize.width() - delta / 2, 0));
    windowA->setTitle(QStringLiteral("Thread A - Context A"));
    windowA->setVisible(true);
    windows.prepend(windowA);

    QList<QThread *> renderThreads;
    if (multipleWindows) {
        QSharedPointer<Renderer> rendererB(new Renderer(format, rendererA.data()));

        QThread *renderThread = new QThread;
        rendererB->moveToThread(renderThread);
        renderThreads << renderThread;

        HelloWindow *windowB = new HelloWindow(rendererA);
        windowB->setGeometry(QRect(center, windowSize).translated(delta / 2, 0));
        windowB->setTitle(QStringLiteral("Thread A - Context A"));
        windowB->setVisible(true);
        windows.prepend(windowB);

        HelloWindow *windowC = new HelloWindow(rendererB);
        windowC->setGeometry(QRect(center, windowSize).translated(-windowSize.width() / 2, windowSize.height() + delta));
        windowC->setTitle(QStringLiteral("Thread B - Context B"));
        windowC->setVisible(true);
        windows.prepend(windowC);

        for (int i = 1; i < QGuiApplication::screens().size(); ++i) {
            QScreen *screen = QGuiApplication::screens().at(i);
            QSharedPointer<Renderer> renderer(new Renderer(format, rendererA.data(), screen));

            renderThread = new QThread;
            renderer->moveToThread(renderThread);
            renderThreads.prepend(renderThread);

            QRect screenGeometry = screen->availableGeometry();
            QPoint center = screenGeometry.center();

            QSize windowSize = screenGeometry.size() * 0.8;

            HelloWindow *window = new HelloWindow(renderer);
            window->setScreen(screen);
            window->setGeometry(QRect(center, windowSize).translated(-windowSize.width() / 2, -windowSize.height() / 2));

            QChar id = QChar('B' + i);
            window->setTitle(QStringLiteral("Thread ") + id + QStringLiteral(" - Context ") + id);
            window->setVisible(true);
            windows.prepend(window);
        }
    }

    for (int i = 0; i < renderThreads.size(); ++i) {
        QObject::connect(qGuiApp, SIGNAL(lastWindowClosed()), renderThreads.at(i), SLOT(quit()));
        renderThreads.at(i)->start();
    }

    const int exitValue = app.exec();

    for (int i = 0; i < renderThreads.size(); ++i)
        renderThreads.at(i)->wait();

    qDeleteAll(windows);
    qDeleteAll(renderThreads);

    return exitValue;
}