Example #1
0
// Triangulate a polygon
void glc::triangulate(QList<GLC_Point2d>& polygon, QList<int>& index, QList<int>& tList)
{
	const int size= polygon.size();
	if (size == 3)
	{
		tList << index[0] << index[1] << index[2];
		return;
	}
	int i0= 0;
	int i1= 1;
	int i2= 2;
	while(i0 < size)
	{
		if (isDiagonal(polygon, i0, i2))
		{
			// Add the triangle before removing the ear.
			tList << index[i0] << index[i1] << index[i2];
			// Remove the ear from polygon and index lists
			polygon.removeAt(i1);
			index.removeAt(i1);
			// recurse to the new polygon
			triangulate(polygon, index, tList);
			return;
		}
		++i0;
		i1= (i1 + 1) % size;
		i2= (i2 + 1) % size;
	}
}
void QSimpleResource::addCustomWidgetsToWidgetDatabase(const QDesignerFormEditorInterface *core,
                                                       QList<DomCustomWidget*>& custom_widget_list)
{
    QDesignerWidgetDataBaseInterface *db = core->widgetDataBase();
    for (int i=0; i < custom_widget_list.size(); ) {
        bool classInserted = false;
        DomCustomWidget *custom_widget = custom_widget_list[i];
        const QString customClassName = custom_widget->elementClass();
        const QString base_class = custom_widget->elementExtends();
        QString includeFile;
        IncludeType includeType = IncludeLocal;
        if (const DomHeader *header = custom_widget->elementHeader()) {
            includeFile = header->text();
            if (header->hasAttributeLocation() && header->attributeLocation() == QStringLiteral("global"))
                includeType = IncludeGlobal;
        }
        const bool domIsContainer = custom_widget->elementContainer();
        // Append a new item
        if (base_class.isEmpty()) {
            WidgetDataBaseItem *item = new WidgetDataBaseItem(customClassName);
            item->setPromoted(false);
            item->setGroup(QCoreApplication::translate("Designer", "Custom Widgets"));
            item->setIncludeFile(buildIncludeFile(includeFile, includeType));
            item->setContainer(domIsContainer);
            item->setCustom(true);
            addFakeMethodsToWidgetDataBase(custom_widget, item);
            db->append(item);
            custom_widget_list.removeAt(i);
            classInserted = true;
        } else {
            // Create a new entry cloned from base class. Note that this will ignore existing
            // classes, eg, plugin custom widgets.
            QDesignerWidgetDataBaseItemInterface *item =
                appendDerived(db, customClassName, QCoreApplication::translate("Designer", "Promoted Widgets"),
                              base_class,
                              buildIncludeFile(includeFile, includeType),
                              true,true);
            // Ok, base class found.
            if (item) {
                // Hack to accommodate for old UI-files in which "container" is not set properly:
                // Apply "container" from DOM only if true (else, eg classes from QFrame might not accept
                // dropping child widgets on them as container=false). This also allows for
                // QWidget-derived stacked pages.
                if (domIsContainer)
                    item->setContainer(domIsContainer);

                addFakeMethodsToWidgetDataBase(custom_widget, static_cast<WidgetDataBaseItem*>(item));
                custom_widget_list.removeAt(i);
                classInserted = true;
            }
        }
        // Skip failed item.
        if (!classInserted)
            i++;
    }

}
void ObjectListener::menuClicked(QAction *action)
{
    int index=-1;
    if(action==wnd->actionQuit)
    {
        wnd->close();
    }else if(action==wnd->actionNew)
    {
        openFile(true);
    }else if(action==wnd->actionClose)
    {
        index=wnd->tabs->currentIndex();
        if(index>-1)
        {
            wnd->tabs->removeTab(index);
            delete wnd->tables.at(index);
            wnd->tables.removeAt(index);
            lisSaveSelect.removeAt(index);
            lsavePath.removeAt(index);
            lisEditable.removeAt(index);
        }
    }else if(action==wnd->actionSave)
    {
        index=wnd->tabs->currentIndex();
        saveFile(false,index);

    }else if(action==wnd->actionSave_as)
    {
        index=wnd->tabs->currentIndex();
        saveFile(true,index);
    }else if(action==wnd->actionOpen)
    {
        openFile(false);
    }else if(action==wnd->actionAbout)
    {
        wnd->about->show();
    }else if(action==wnd->pActionEdit.data())
    {
        index=wnd->tabs->currentIndex();
        if(index>-1)
            tableDoubleClicked(wnd->tables[index]->currentIndex());
    }else if(action==wnd->pActionRemove.data())
    {
        index=wnd->tabs->currentIndex();
        if(index>-1)
            deleteItem(index);
    }
}
Example #4
0
QList<Team> FourMatchesContest::teamsAvailableToPlayAgainst(const Team& team, const QList<Team> &teamsToPlayAgainst )
{
  QList<Team> ret = teamsToPlayAgainst.mid( 1 );

    for( int i = 0; i < ret.size(); ++i ) {
        Team currentTeam = ret.at( i );
        if( currentTeam == team ) continue;

        bool alreadyExists = false;
        if ( mFirstPhase != NULL ) {
          alreadyExists |= mFirstPhase->exists( Match( team, currentTeam ) )
                          || mFirstPhase->exists( Match( currentTeam, team ) );
        }
        if ( mSecondPhase != NULL ) {
          alreadyExists |= mSecondPhase->exists( Match( team, currentTeam ) )
                          || mSecondPhase->exists( Match( currentTeam, team ) );
        }
        if ( mThirdPhase != NULL ) {
          alreadyExists |= mThirdPhase->exists( Match( team, currentTeam ) )
                          || mThirdPhase->exists( Match( currentTeam, team ) );
        }
        if ( mFourthPhase != NULL ) {
          alreadyExists |= mFourthPhase->exists( Match( team, currentTeam ) )
                          || mFourthPhase->exists( Match( currentTeam, team ) );
        }

        if ( alreadyExists ) {
          ret.removeAt( i );
          --i;
        }
    }
    return ret;
}
Example #5
0
void MessageWind::on_action_Delete_triggered()  //删除联系人
{
    QTreeWidgetItem *item= ui->contactsTreeWidget->currentItem();
    Contact temp=texttocontact(item->whatsThis(0));
    QList<Contact> *contactlist;
    int position;
    indexofcontact(temp.number,&contactlist,&position);
    contactlist->removeAt(position); //删除联系人对象
    ui->contactsTreeWidget->removeItemWidget(item,0);
    for(int i=0;i<childBlinkItems.count();i++)  //删除存在的闪烁
    {
        if(childBlinkItems[i]->getitem()==item)
        {
            Blink *tmp=childBlinkItems[i];
            childBlinkItems.removeAt(i);
            delete tmp;
            i--;
        }
    }

    for(int i=0;i<chats.count();i++)    //删除该联系人的聊天窗口
    {
        if(chats[i]->getcontact().name==temp.name&&chats[i]->getcontact().number==temp.number)
        {
            Chat *chat=chats[i];
            chats.removeAt(i);
            delete chat;
            i--;
        }
    }
    delete item;
}
// The dtor.
QsciScintillaBase::~QsciScintillaBase()
{
    // Remove it from the pool.
    poolList.removeAt(poolList.indexOf(this));

    delete sci;
}
Example #7
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();
}
Example #8
0
void MainWindow::drawCouples()
{
    ui->couples->clear();
    int tc = teams.count();
    QList <int> numbers;
    for (int i = 0; i < tc; ++i)
        numbers.append(i);
    bool left = true;
    while (numbers.count() != 0) {
        int curi = qrand() % numbers.count();
        int cur = numbers.at(curi);
        numbers.removeAt(curi);
        if (left) {
            ui->couples->appendPlainText(
                        teams.at(cur)->number->text()
                        + " " + teams.at(cur)->name->text().trimmed());
            left = false;
        } else {
            ui->couples->insertPlainText(
                        " <-> " + teams.at(cur)->number->text()
                        + " " + teams.at(cur)->name->text().trimmed());
            left = true;
        }
    }
}
/**
 * Move a entity list in this container at the given position,
 * the borders of this entity-container if autoUpdateBorders is true.
 */
void RS_EntityContainer::moveEntity(int index, QList<RS_Entity *>& entList){
    if (entList.isEmpty()) return;
    int ci = 0; //current index for insert without invert order
    bool ret, into = false;
    RS_Entity *mid = NULL;
    if (index < 1) {
        ci = 0;
    } else if (index >= entities.size() ) {
        ci = entities.size() - entList.size();
    } else {
        into = true;
        mid = entities.at(index);
    }

    for (int i = 0; i < entList.size(); ++i) {
        RS_Entity *e = entList.at(i);
        ret = entities.removeOne(e);
        //if e not exist in entities list remove from entList
        if (!ret) {
            entList.removeAt(i);
        }
    }
    if (into) {
        ci = entities.indexOf(mid);
    }

	for(auto e: entList){
            entities.insert(ci++, e);
    }
}
Example #10
0
bool ConsolePlan::removeSpot(float angle, Plane2DCoordinate coordinate)
{
    QString str;
    if (m_planeSpots.contains(angle))
    {
        QList<Plane2DCoordinate> coordinates = m_planeSpots.value(angle);
        int i = containSpot(coordinates,coordinate);
        if (i >= 0)
        {
            coordinates.removeAt(i);
            if (coordinates.size() == 0)
            {
                m_planeSpots.remove(angle);
            }else
            {
                m_planeSpots.insert(angle,coordinates);
            }

            str = printLastAction(RemoveSpot) + printLastError(NoError);
            qCDebug(PlanGenerator()) << PlanGenerator().categoryName() << str;
            return true;
        }else
        {
            str = printLastAction(RemoveSpot) + printLastError(ErrorPlaneNoSuchSpot);
            qCDebug(PlanGenerator()) << PlanGenerator().categoryName() << str;
            return false;
        }
    }else
    {
        str = printLastAction(RemoveSpot) + printLastError(ErrorNoSuchPlane);
        qCWarning(PlanGenerator()) << PlanGenerator().categoryName() << str;
        emit error(ErrorNoSuchPlane);
        return false;
    }
}
void OrderManager::orderItems()
{
	//			initialize the position array
	QList<QPointF> available;
	for( int index = 0; index < list.length(); index++)
	{
		QPointF ava((index % num_Wid) * Width + Width/2 ,(index - (index % num_Wid))/num_Wid*Width + Width/2);
		available.append( ava );
	}
	int left = list.length();
	while( left != 0)
	{
		QPointF cur_Point = list[left - 1];
		int cur_cost = 999999;
		int index;
		for( int i = 0; i < left; i++)
		{
			if( cost( cur_Point, available[i] ) < cur_cost)
			{
				cur_cost = cost( cur_Point, available[i] );
				index = i;
			}
		}
		list.replace( left - 1, available[ index ]);
		available.removeAt( index );
		left -= 1;
	}
	return;
}
Example #12
0
void MainUI::GoForward(){
  QList<QWebHistoryItem> bits = webview->history()->forwardItems(50); //max 50 items
  //First remove any action URLs (*never* repeat them)
  for(int i=0; i<bits.length(); i++){
    if( actionUrl(bits[i].url()) ){ bits.removeAt(i); i--; }
  }
  //Now go through and find the proper URL to go to
  QUrl cit = webview->url(); //current page URL
  if(DEBUG){ qDebug() << "---FORWARD CLICKED---" << bits.length(); }
  //Go to the last page-refresh (if any) for the next URL
  int got = -1; // go to index
  for(int i=0; i<bits.length() && got<0; i++){ //i=0 is the desired item
    if( !sameUrls(cit, bits[i].url()) ){
      got = i; //go to this URL (different from current page)
      //Now fast forward to the end of the page-refresh chain (if there is one) for this URL
      for(int j=i+1; j<bits.length(); j++){
        if( sameUrls( bits[i].url(), bits[j].url()) ){ got = j; }
	else{ break; }
      }
    }else if(i==(bits.length()-1)){
      got = i; //last item - go ahead and load it
    }
    if(DEBUG && got < 0){ qDebug() << "Forward History Item Skipped:" << i << bits[i].url(); }
  }
  //fallback in case something above did not work
  if(got<0){ webview->forward(); }
  else{ 
    webview->history()->goToItem(bits[got]); 
  }
}
Example #13
0
QStringList SessionManagerPrivate::dependenciesOrder() const
{
    QList<QPair<QString, QStringList> > unordered;
    QStringList ordered;

    // copy the map to a temporary list
    foreach (Project *pro, m_projects) {
        const QString &proName = pro->projectFilePath();
        unordered << QPair<QString, QStringList>(proName, m_depMap.value(proName));
    }

    while (!unordered.isEmpty()) {
        for (int i=(unordered.count()-1); i>=0; --i) {
            if (unordered.at(i).second.isEmpty()) {
                ordered << unordered.at(i).first;
                unordered.removeAt(i);
            }
        }

        // remove the handled projects from the dependency lists
        // of the remaining unordered projects
        for (int i = 0; i < unordered.count(); ++i) {
            foreach (const QString &pro, ordered) {
                QStringList depList = unordered.at(i).second;
                depList.removeAll(pro);
                unordered[i].second = depList;
            }
        }
    }
Example #14
0
bool CrateFeature::dropAcceptChild(const QModelIndex& index, QList<QUrl> urls,
                                   QObject* pSource) {
    int crateId = crateIdFromIndex(index);
    if (crateId == -1) {
        return false;
    }
    QList<QFileInfo> files = DragAndDropHelper::supportedTracksFromUrls(urls, false, true);
    QList<int> trackIds;
    if (pSource) {
        trackIds = m_pTrackCollection->getTrackDAO().getTrackIds(files);
        m_pTrackCollection->getTrackDAO().unhideTracks(trackIds);
    } else {
        // Adds track, does not insert duplicates, handles unremoving logic.
        trackIds = m_pTrackCollection->getTrackDAO().addTracks(files, true);
    }
    qDebug() << "CrateFeature::dropAcceptChild adding tracks"
            << trackIds.size() << " to crate "<< crateId;
    // remove tracks that could not be added
    for (int trackId = 0; trackId < trackIds.size(); ++trackId) {
        if (trackIds.at(trackId) < 0) {
            trackIds.removeAt(trackId--);
        }
    }
    m_crateDao.addTracksToCrate(crateId, &trackIds);
    return true;
}
Example #15
0
void MiaMarkerStatistics::scanBifurcations()
{
    for(int i = 0; i < markerList.size(); i++ )
    {
        MiaMarker3DPolygon* markerA = (MiaMarker3DPolygon*)markerList.at(i);
        markerA->bifurcationNodeList.clear();
        QList<int> bptlist;
        for(int j = 0; j < markerList.size();j++)
        {
            if(i == j)
                continue;
            MiaMarker3DPolygon* markerB = (MiaMarker3DPolygon*)markerList.at(j);

            QList<int> bpoints = findBifurcationPoints(markerA->keyPointList,markerB->keyPointList);
            bptlist.append(bpoints);
        }
        qSort(bptlist);
        qDebug()<<bptlist;
        for(int j = bptlist.size() - 1; j >= 0 ; j--)
        {
            //remove redundant points
            if(j>0 && bptlist[j] - bptlist[j-1] < 50)
                bptlist.removeAt(j);
        }
        if(bptlist.size()>0)
        {
            if(bptlist.first()!=0)
                markerA->bifurcationNodeList.append(0);
            markerA->bifurcationNodeList.append(bptlist);
            if(bptlist.last() != markerA->keyPointList.size()-1)
                markerA->bifurcationNodeList.append(markerA->keyPointList.size()-1);
        }
        qDebug()<<markerA->bifurcationNodeList;
    }
}
Example #16
0
void XSqlQuery::removeErrorListener(XSqlQueryErrorListener* listener)
{
  int i = _errorListeners.indexOf(listener);
  while(-1 != i)
  {
    _errorListeners.removeAt(i);
    i = _errorListeners.indexOf(listener);
  }
}
Example #17
0
void MenuManager::setup(MenuItem* menuItems) const
{
    if (!menuItems)
        return; // empty menu bar

    QMenuBar* menuBar = getMainWindow()->menuBar();
    //menuBar->setUpdatesEnabled(false);

    QList<MenuItem*> items = menuItems->getItems();
    QList<QAction*> actions = menuBar->actions();
    for (QList<MenuItem*>::ConstIterator it = items.begin(); it != items.end(); ++it)
    {
        // search for the menu action
        QAction* action = findAction(actions, QString::fromAscii((*it)->command().c_str()));
        if (!action) {
            // There must be not more than one separator in the menu bar, so
            // we can safely remove it if available and append it at the end
            if ((*it)->command() == "Separator") {
                action = menuBar->addSeparator();
                action->setObjectName(QLatin1String("Separator"));
            }
            else {
                // create a new menu
                std::string menuName = (*it)->command();
                QMenu* menu = menuBar->addMenu(
                    QApplication::translate("Workbench", menuName.c_str(),
                                            0, QApplication::UnicodeUTF8));
                action = menu->menuAction();
                menu->setObjectName(QString::fromAscii(menuName.c_str()));
                action->setObjectName(QString::fromAscii(menuName.c_str()));
            }

            // set the menu user data
            action->setData(QString::fromAscii((*it)->command().c_str()));
        }
        else {
            // put the menu at the end
            menuBar->removeAction(action);
            menuBar->addAction(action);
            action->setVisible(true);
            int index = actions.indexOf(action);
            actions.removeAt(index);
        }

        // flll up the menu
        if (!action->isSeparator())
            setup(*it, action->menu());
    }

    // hide all menus which we don't need for the moment
    for (QList<QAction*>::Iterator it = actions.begin(); it != actions.end(); ++it) {
        (*it)->setVisible(false);
    }

    // enable update again
    //menuBar->setUpdatesEnabled(true);
}
Example #18
0
void QMenuBarPrivate::wceDestroyMenuBar()
{
    Q_Q(QMenuBar);
    int index = nativeMenuBars.indexOf(q);
    nativeMenuBars.removeAt(index);
    if (wce_menubar) {
        delete wce_menubar;
        wce_menubar = 0;
    }
}
Example #19
0
void Preferences::removeUserLayout(int index)
{
  int userLayoutIndex = this->m_Data[UserLayoutIndex].toInt();
  QList<QVariant> userLayouts = this->m_Data[UserLayouts].toList();
  userLayouts.removeAt(index*2); // Name
  userLayouts.removeAt(index*2); // Data
  if ((userLayoutIndex != -1) && (userLayoutIndex == index + 3))
    userLayoutIndex = 0;
  this->m_Data[UserLayoutIndex] = userLayoutIndex;
  this->m_Data[UserLayouts] = userLayouts;
};
Example #20
0
SI_SymbolPin* SES_DrawWire::findSymbolPin(Schematic&   schematic,
                                          const Point& pos) const noexcept {
  QList<SI_SymbolPin*> items = schematic.getPinsAtScenePos(pos);
  for (int i = items.count() - 1; i >= 0; --i) {
    // only choose pins which are connected to a component signal!
    if (!items.at(i)->getComponentSignalInstance()) {
      items.removeAt(i);
    }
  }
  return (items.count() > 0) ? items.first() : nullptr;
}
Example #21
0
    ZVariant removeAt(const QList<ZVariant> &args)
    {
        if (args.count() > 1) {
            QList<ZVariant> list = args.first().toList();

            list.removeAt(args.at(1).toInt());
            args.first().depthCopyAssign(list);
        }

        return args.first();
    }
Example #22
0
void unpostedGlSeries::removeDupAltIds(QList<QTreeWidgetItem*> & list)
{
    for (int i = 0; i < list.size(); i++)
    {
        for (int j = i + 1; j < list.size(); j++)
        {
            if (((XTreeWidgetItem*)(list[i]))->altId() ==
                    ((XTreeWidgetItem*)(list[j]))->altId())
                list.removeAt(j);
        }
    }
}
Example #23
0
void QgsNewHttpConnection::accept()
{
    QSettings settings;
    QString key = mBaseKey + txtName->text();
    QString credentialsKey = "/Qgis/" + mCredentialsBaseKey + "/" + txtName->text();

    // warn if entry was renamed to an existing connection
    if (( mOriginalConnName.isNull() || mOriginalConnName != txtName->text() ) &&
            settings.contains( key + "/url" ) &&
            QMessageBox::question( this,
                                   tr( "Save connection" ),
                                   tr( "Should the existing connection %1 be overwritten?" ).arg( txtName->text() ),
                                   QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
    {
        return;
    }

    // on rename delete original entry first
    if ( !mOriginalConnName.isNull() && mOriginalConnName != key )
    {
        settings.remove( mBaseKey + mOriginalConnName );
        settings.remove( "/Qgis/" + mCredentialsBaseKey + "/" + mOriginalConnName );
    }

    QUrl url( txtUrl->text().trimmed() );

    QList< QPair<QByteArray, QByteArray> > params = url.encodedQueryItems();
    for ( int i = 0; i < params.size(); i++ )
    {
        if ( params[i].first.toUpper() == "SERVICE" ||
                params[i].first.toUpper() == "REQUEST" ||
                params[i].first.toUpper() == "FORMAT" )
        {
            params.removeAt( i-- );
        }
    }
    url.setEncodedQueryItems( params );

    settings.setValue( key + "/url", url.toString() );
    if ( mBaseKey == "/Qgis/connections-wms/" )
    {
        settings.setValue( key + "/ignoreGetMapURI", cbxIgnoreGetMapURI->isChecked() );
        settings.setValue( key + "/ignoreGetFeatureInfoURI", cbxIgnoreGetFeatureInfoURI->isChecked() );
    }

    settings.setValue( credentialsKey + "/username", txtUserName->text() );
    settings.setValue( credentialsKey + "/password", txtPassword->text() );

    settings.setValue( mBaseKey + "/selected", txtName->text() );

    QDialog::accept();
}
    // refresh all widgets of a day
    void refreshDayWidgets(const QDate &dayDate)
    {
//        Q_ASSERT(q->model());
        if (!q->model())
            return;

        if (dayDate < q->firstDate()
                || dayDate >= q->firstDate().addDays(m_rangeWidth)
                || dayDate.isNull()
                || !dayDate.isValid()) // day is out of range
            return;

        // at first remove all day widgets
        qDeleteAll(q->getWidgetsByDate(dayDate));

        // get the new items from this date
        QList<CalendarItem> items = q->model()->getItemsBetween(dayDate, dayDate);

        // remove full day items
        for (int i = items.count() - 1; i >= 0; i--) {
            const CalendarItem &item = items[i];
            if (item.beginningType() == Date_Date || item.endingType() == Date_Date)
                items.removeAt(i);
        }
        if (!items.count())
            return;

        // sorting and create the tree
        qSort(items.begin(), items.end(), calendarItemLessThan);

        HourRangeNode::setHourHeight(m_hourHeight);
        HourRangeNode::setMinimumItemHeight(DayRangeBody::m_minimumItemHeight);
        HourRangeNode node(items[0]);

        for (int i = 1; i < items.count(); i++)
            node.store(items[i]);

        node.prepareForWidthsComputing();
        QList<HourRangeNode*> nodes;
        QPair<int, int> band = getBand(dayDate);
        node.computeWidths(band.first, band.second, nodes);

        foreach (HourRangeNode *node, nodes) {
            HourRangeWidget *widget = new HourRangeWidget(q, node->item().uid(), q->model());
            QPair<int, int> verticalData = getItemVerticalData(node->item().beginning().time(), node->item().ending().time());
            widget->setBeginDateTime(node->item().beginning());
            widget->setEndDateTime(node->item().ending());
            widget->move(node->left(), verticalData.first);
            widget->resize(node->width(), verticalData.second);
            widget->show();
        }
//needs handling if we should delete the plugins or not and save there content
void RackWindow::closePluginHost(QWidget *pluginHost)
{
    RSplitter *splitter = qobject_cast<RSplitter *>(pluginHost->parent());
    RSplitter *parentSplitter = qobject_cast<RSplitter *>(splitter->parent());
    if (!parentSplitter && splitter->count() == 1) return;
    if (splitter->count() > 2)
    {
        QList<int> widgetsizes = splitter->sizes();
        int senderpos = splitter->indexOf(pluginHost);
        if (senderpos == widgetsizes.count()-1)
        {
            widgetsizes.replace(senderpos-1, widgetsizes.at(senderpos-1) + widgetsizes.at(senderpos));
        }
        else
        {
            widgetsizes.replace(senderpos, widgetsizes.at(senderpos) + widgetsizes.at(senderpos+1));
            widgetsizes.removeAt(senderpos + 1);
        }
        delete pluginHost->property("pluginToolBar").value<QToolBar *>();
        pluginHost->setProperty("pluginToolBar", 0);
        delete pluginHost;
        pluginHost = 0;
        splitter->setSizes(widgetsizes);
    }
    else {
        delete pluginHost->property("pluginToolBar").value<QToolBar *>();
        pluginHost->setProperty("pluginToolBar", 0);
        delete pluginHost;
        pluginHost = 0;
    }
    if (splitter->count()==1 && parentSplitter)
    {
        parentSplitter->insertWidget(parentSplitter->indexOf(splitter), splitter->widget(0));
        delete splitter;
        splitter = 0;
    }


    ///test
//    if (m_pluginLoader->unload()) {

//        delete m_pluginLoader;
//        m_pluginLoader = 0;
//        qDebug() << "unloaded";
//    }

    //////////////////

//    QList<RSplitter *> splitters = findChildren<RSplitter *>();
//    qDebug("splitter count: %d", splitters.size());
}
Example #26
0
void db::getAllPhotos(QList<photo*>* pl,QList<face*>* faceList){
	bool a=false;
	QSqlQuery query(database);
	// "SELECT DISTINCT F.Fid,I.Iid,F.x,F.y,F.width,F.height,F.tw,F.th,I.path,P.name FROM Faces F,HasFaces H,Images I,Person P WHERE F.Fid=H.Fid AND P.Pid=H.Pid AND H.Iid=I.Iid AND I.Iid IN (SELECT I1.Iid FROM Images I1,HasFaces H1,Faces F1,Person P1 WHERE F1.Fid=H1.Fid AND P1.Pid=H1.Pid AND H1.Iid=I1.Iid AND P1.name=:personName)");
	query.prepare("SELECT DISTINCT F.Fid,I.Iid,F.x,F.y,F.width,F.height,F.tw,F.th,I.path,P.name,F.feature FROM Faces F,HasFaces H,Images I,Person P WHERE F.Fid=H.Fid AND P.Pid=H.Pid AND H.Iid=I.Iid AND I.Iid IN (SELECT I1.Iid FROM Images I1,HasFaces H1,Faces F1,Person P1 WHERE F1.Fid=H1.Fid AND P1.Pid=H1.Pid AND H1.Iid=I1.Iid )");
	//	query.bindValue(":personName", personName);
	a=query.exec();

	QList<face*> fl;
	QList<int> imageIdList;
	QList<QString> pathList;

	while(query.next()){
		int faceId = query.value(0).toInt();
		int imageId = query.value(1).toInt();
		double x=query.value(2).toDouble();
		double y=query.value(3).toDouble();
		double width=query.value(4).toDouble();
		double height=query.value(5).toDouble();
		double tw=query.value(6).toDouble(); 
		double th=query.value(7).toDouble();
		QString path = query.value(8).toString();
		QString name = query.value(9).toString();
		QString featStr = query.value(10).toString();
		if(!imageIdList.contains(imageId)){
			imageIdList.append(imageId);
			pathList.append(path);
		}
		double* flist = returnFacialFeatures(featStr);
		face* f = new face(faceId,QStringToString(path),x,y,width,height,tw,th,flist,QStringToString(name));
		f->setPhotoID(imageId);

		fl.append(f);
		faceList->append(f);
	}
	//	QList<photo*>* pl = new QList<photo*>();
	for(int i = 0; i<imageIdList.size();i++){
		QList<face*> *pfl = new QList<face*>(); 
		for(int j = 0; j<fl.size();j++){
			if(fl[j]->getPhotoId() == imageIdList[i]){
				pfl->append(fl[j]);
				fl.removeAt(j);
				j--;
			}
		}
		photo* np = new photo(pathList[i],pfl);
		np->setID(imageIdList[i]);
		pl->append(np);
	}
}
Example #27
0
void MountTray::slotOpenAVDisk(QString type){
  if(MTINIT){ return; } //don't open the launcher during program initialization
  //Get the list of all AudioVideo Applications on the sytem
  QList<XDGFile> apps = XDGUtils::allApplications();
  apps = XDGUtils::filterAppsByCategory("AudioVideo", apps);
  apps = XDGUtils::sortAppsByName(apps);
  //Now generate the QStringList of application names
  QStringList names;
  for(int i=0; i<apps.length(); i++){
    //Filter out "invalid" applications (mixers, etc..)
    QString rname = apps[i].RawName();
    if(rname.contains("mixer", Qt::CaseInsensitive) || rname.contains("control", Qt::CaseInsensitive) ){ 
	//skip it
	apps.removeAt(i);
	i--;
    }else{
      QString txt;
      if( apps[i].Comment().isEmpty() ){ txt = apps[i].Name(); }
      else{ txt = apps[i].Name() +" ("+apps[i].Comment()+")"; }
      //Make sure that UMPlayer is listed first and recommended
      if(apps[i].RawName().toLower()=="umplayer"){
	 txt = apps[i].Name()+ "  **"+tr("Recommended")+"**"; 
	 names.prepend(txt); //put at the top
	 apps.move(i,0); //move the file to the front as well
      }else{
	 names << txt;
      }
    }
  }
  //Prompt for the user to select an application
  bool ok = false;
  QString appname = QInputDialog::getItem(0, QString(tr("%1 Disk")).arg(type) , tr("Open With:"), names,0, false, &ok);
  if(!ok || appname.isEmpty()){ return; }
  int index = names.indexOf(appname);
  if(index == -1){ return; }
  //Now start the application
  qDebug() << "Open "+type.toLower()+" disk:";
  qDebug() << " -- With:"<<appname;
  QString cmd = apps[index].Exec();
  //Only auto-start the disk with UMPlayer - no guarantee this method works for other apps
  if(apps[index].RawName().toLower()=="umplayer"){
    if(type.toLower()=="audio"){
      cmd.append(" cdda://1"); //audio cd
    }else{ //video DVD
      cmd.append(" dvd://1"); //video dvd
    }
  }
  qDebug() << " -- Exec:" << cmd;
  QProcess::startDetached( cmd );
}
Example #28
0
bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent)
{
    if (parent.isValid())
        return false;
    int lastRow = row + count - 1;
    beginRemoveRows(parent, row, lastRow);
    QList<HistoryEntry> lst = m_history->history();
    for (int i = lastRow; i >= row; --i)
        lst.removeAt(i);
    disconnect(m_history, SIGNAL(historyReset()), this, SLOT(historyReset()));
    m_history->setHistory(lst);
    connect(m_history, SIGNAL(historyReset()), this, SLOT(historyReset()));
    endRemoveRows();
    return true;
}
Example #29
0
QList<Jugador> Ranking:: ordenarRanking(QList<Jugador> ranking){
    QList<Jugador> ordenado;
    int i,pos;
    while(ranking.size()!=0){
        pos=0;
        for(i=1;i<ranking.size();i++){
            Jugador j1=ranking.at(pos);
            Jugador j2=ranking.at(i);
            if(j1.getPuntaje()>j2.getPuntaje())
                pos=i;
        }
        ordenado.append(ranking.at(pos));
        ranking.removeAt(pos);
    }
    return ordenado;
}
Example #30
0
void MessageWind::havenewSms()         //提取新消息
{
    QList<Message> *smsset;
    for(int i=0;i<clients.count();i++)
    {
        if(clients[i]->haveread())
        {
            smsset=clients[i]->getSms();
            for(int j=0;j<smsset->count();j++)
            {
                insertSms((*smsset)[j]);
                smsset->removeAt(j);
                j--;
            }
        }
    }
}