示例#1
0
文件: setup.cpp 项目: icefox/kinkatta
/***************************************************************************
 * Reset the default settings.
 ***************************************************************************/
void setup::resetDefaults(){
  removeGroup("away");
  //removeGroup("away list");
  removeGroup("chat");
  removeGroup("general");
  removeGroup("network");
  removeGroup("sound");

  read();
}
/*! \brief show the context menu
 */
void XletSwitchBoard::contextMenuEvent(QContextMenuEvent *event)
{
    // check if there is a group under the cursor
    Group *group = getGroup(m_layout->getPosInGrid(event->pos()));

    QMenu contextMenu(this);
    QAction *action;
    if (group) {
        action = contextMenu.addAction(tr("Remove group %1").arg(group->name()),
                                       this, SLOT(removeGroup()));
        action->setProperty("group", QVariant::fromValue((void *)group));

        action = contextMenu.addAction(tr("Change color of group %1").arg(group->name()),
                                       this, SLOT(changeGroupColor()));
        action->setProperty("group", QVariant::fromValue((void *)group));

        action = contextMenu.addAction(tr("Rename group %1").arg(group->name()),
                                       this, SLOT(changeGroupName())); 
        action->setProperty("group", QVariant::fromValue((void *)group));
    }

    action = contextMenu.addAction(tr("Add Phone number entry"),
                                   this, SLOT(addPhoneNumberEntry()));
    action->setProperty("pos", m_layout->getPosInGrid(event->pos()));

    action = new QAction(tr("Draw the grid"), this);
    action->setCheckable(true);
    action->setChecked(m_drawGrid);
    connect(action, SIGNAL(toggled(bool)),
            this, SLOT(drawTheGrid(bool)));
    contextMenu.addAction(action);

    contextMenu.exec(event->globalPos());
}
示例#3
0
void Widget::clearContactsList()
{
    QList<Friend*> friends = FriendList::getAllFriends();
    for (Friend* f : friends)
        removeFriend(f);
    for (Group* g : GroupList::groupList)
        removeGroup(g);
}
示例#4
0
Scene::~Scene()
{
	// Delete all scene items and groups cleanly
	m_isDestructing = true;
	while(!m_groups.isEmpty())
		removeGroup(m_groups.last().group);
	m_profile->pruneLayerGroups(); // As it's disabled in `removeGroup()`
}
示例#5
0
文件: widget.cpp 项目: AWeinb/qTox
void Widget::clearContactsList()
{
    QList<Friend*> friends = FriendList::getAllFriends();
    for (Friend* f : friends)
        removeFriend(f, true);

    QList<Group*> groups = GroupList::getAllGroups();
    for (Group* g : groups)
        removeGroup(g, true);
}
示例#6
0
void KNCollectionView::removeAccount(KNNntpAccount *a)
{
    if(!a->listItem())
        return;
    KNCollectionViewItem *child = 0, *aitem = a->listItem();
    while((child = static_cast<KNCollectionViewItem *>(aitem->firstChild())))
        removeGroup(static_cast<KNGroup *>(child->coll));
    delete aitem;
    a->setListItem(0);
}
示例#7
0
文件: groupwidget.cpp 项目: qTox/qTox
void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
{
    if (!active) {
        setBackgroundRole(QPalette::Highlight);
    }

    installEventFilter(this); // Disable leave event.

    QMenu menu(this);

    QAction* openChatWindow = nullptr;
    QAction* removeChatWindow = nullptr;

    // TODO: Move to model
    ContentDialog* contentDialog = ContentDialogManager::getInstance()->getGroupDialog(groupId);
    const bool notAlone = contentDialog != nullptr && contentDialog->chatroomWidgetCount() > 1;

    if (contentDialog == nullptr || notAlone) {
        openChatWindow = menu.addAction(tr("Open chat in new window"));
    }

    if (contentDialog && contentDialog->hasContactWidget(groupId)) {
        removeChatWindow = menu.addAction(tr("Remove chat from this window"));
    }

    menu.addSeparator();

    QAction* setTitle = menu.addAction(tr("Set title..."));
    QAction* quitGroup = menu.addAction(tr("Quit group", "Menu to quit a groupchat"));

    QAction* selectedItem = menu.exec(event->globalPos());

    removeEventFilter(this);

    if (!active) {
        setBackgroundRole(QPalette::Window);
    }

    if (!selectedItem) {
        return;
    }

    if (selectedItem == quitGroup) {
        emit removeGroup(groupId);
    } else if (selectedItem == openChatWindow) {
        emit newWindowOpened(this);
    } else if (selectedItem == removeChatWindow) {
        // TODO: move to model
        ContentDialog* contentDialog = ContentDialogManager::getInstance()->getGroupDialog(groupId);
        contentDialog->removeGroup(groupId);
    } else if (selectedItem == setTitle) {
        editName();
    }
}
void Ut_DBusInterfaceNotificationSink::init()
{
    qDBusConnectionConnectService.clear();
    qDBusConnectionConnectPath.clear();
    qDBusConnectionConnectInterface.clear();
    qDBusConnectionConnectName.clear();
    qDBusConnectionConnectReceiver.clear();
    qDBusConnectionConnectSlot.clear();

    manager = new NotificationManager;
    sink = new DBusInterfaceNotificationSink(manager);

    connect(this, SIGNAL(addNotification(Notification)), sink, SLOT(addNotification(Notification)));
    connect(this, SIGNAL(addGroup(uint,NotificationParameters)), sink, SLOT(addGroup(uint,NotificationParameters)));
    connect(this, SIGNAL(removeNotification(uint)), sink, SLOT(removeNotification(uint)));
    connect(this, SIGNAL(removeGroup(uint)), sink, SLOT(removeGroup(uint)));
    gNotificationManagerStub->stubReset();

    gNotificationGroupStub->stubReset();
    gNotificationGroupStub->stubSetReturnValue<const NotificationParameters&>("parameters", fakeParams);
}
示例#9
0
void DrMain::removeOptionGlobally(const QString &name)
{
    DrGroup *grp(0);
    DrBase *opt = findOption(name, &grp);

    if(opt && grp)
    {
        grp->removeOption(name);
        if(grp->isEmpty())
            removeGroup(grp);
    }
}
示例#10
0
bool SSIManager::removeGroup( const QString &group )
{
    Oscar::SSI gr = findGroup( group );

    if ( gr.isValid() && removeGroup( gr )  )
    {
        return true;
    }
    else
        kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Group " << group << " not found." << endl;

    return false;
}
示例#11
0
int AgentLuaInterface::l_removeGroup(lua_State *L)
{
    int id = lua_tonumber(L, -2);
    int group = lua_tonumber(L, -1);
    bool removed = false;

    auto autonPtr = Interfacer::getAgentPtr(id);
    if (autonPtr != NULL)
    {
        removed = autonPtr->removeGroup(group);
    }

    lua_pushboolean(L, removed);
    return 1;
}
void Ut_DBusInterfaceNotificationSink::testNothingCalledWhenNothingRegistered()
{
    Notification n;
    NotificationParameters np;

    emit addNotification(n);
    emit addGroup(0, np);
    emit removeNotification(0);
    emit removeGroup(0);

    QCOMPARE(gAddNotificationProxies.count(), 0);
    QCOMPARE(gAddGroupProxies.count(), 0);
    QCOMPARE(gRemoveNotificationProxies.count(), 0);
    QCOMPARE(gRemoveGroupProxies.count(), 0);
}
示例#13
0
文件: Merge.cpp 项目: hoijui/E323AI
// called on Group removing
void MergeTask::remove(ARegistrar &group) {
	CGroup *g = dynamic_cast<CGroup*>(&group);
	
	assert(g != NULL);	

	bool isReelectionNeeded = (masterGroup && masterGroup->key == g->key);
	
	mergable.erase(g->key);
	removeGroup(*g);

	if (isReelectionNeeded) {
		masterGroup = NULL;
		reelectMasterGroup();
	}
}
示例#14
0
GroupsTab::GroupsTab(GroupManager* manager, QWidget* parent): QWidget(parent)
{
    this->manager = manager;
    //scrollArea = new QScrollArea(this);
    //scrollArea->setLayout(scrolledLayout);
    //scrolledWidget = new QWidget(scrollArea);
    //scrolledWidget = scrollArea;
    //scrolledLayout = new QVBoxLayout(scrolledWidget);
    layout = new QVBoxLayout(this);
    foreach(QString name, manager->groupNames())
	createGroup(name);
    //scrollArea->setWidget(scrolledWidget);
    //layout->addWidget(scrollArea);
    QObject::connect(manager, SIGNAL(groupCreated(QString)), this, SLOT(createGroup(QString)));
    QObject::connect(manager, SIGNAL(groupRemoved(QString)), this, SLOT(removeGroup(QString)));
}
示例#15
0
void ContentDialog::onChatroomWidgetClicked(GenericChatroomWidget *widget, bool group)
{
    if (group)
    {
        ContentDialog* contentDialog = new ContentDialog(settingsWidget);
        contentDialog->show();

        if (widget->getFriend() != nullptr)
        {
            removeFriend(widget->getFriend()->getFriendID());
            Widget::getInstance()->addFriendDialog(widget->getFriend(), contentDialog);
        }
        else
        {
            removeGroup(widget->getGroup()->getGroupId());
            Widget::getInstance()->addGroupDialog(widget->getGroup(), contentDialog);
        }

        contentDialog->raise();
        contentDialog->activateWindow();

        return;
    }

    // If we clicked on the currently active widget, don't reload and relayout everything
    if (activeChatroomWidget == widget)
        return;

    contentLayout->clear();

    if (activeChatroomWidget != nullptr)
        activeChatroomWidget->setAsInactiveChatroom();

    activeChatroomWidget = widget;

    widget->setChatForm(contentLayout);
    widget->setAsActiveChatroom();
    widget->resetEventFlags();
    widget->updateStatusLight();
    updateTitle(widget);

    if (widget->getFriend())
        widget->getFriend()->getFriendWidget()->updateStatusLight();
    else
        widget->getGroup()->getGroupWidget()->updateStatusLight();
}
示例#16
0
MainMenuItem::MainMenuItem()
  : m_defaultItemSize( 55 )
{
  m_timer.setSingleShot( true );
  connect( &m_timer, SIGNAL( timeout() ), SLOT( hideItems() ) );

  setItemSize( m_defaultItemSize );

  setBrush( QColor( 230,229,229 ) );

  QPen pen;
  pen.setBrush( Qt::NoBrush );
  setPen( pen );

  QGraphicsTextItem *textItem = new QGraphicsTextItem( i18n("Menu"), this );

  int textWidth = textItem->boundingRect().width();
  int textHeight = textItem->boundingRect().height();

  textItem->setPos( - textWidth / 2, - textHeight / 2 );

  m_fanMenu = new FanMenu( this );
  m_fanMenu->setZValue( 50 );
  m_fanMenu->hide();
  m_fanMenu->setStartAngle( 170 );
  m_fanMenu->setEndAngle( 280 );
  m_fanMenu->setRadius( 220 );
  m_fanMenu->setSpacing( 5 );

  FanMenuItem *menuItem = m_fanMenu->addItem( i18n("Clone\ngroup") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( cloneGroup() ) );
  menuItem = m_fanMenu->addItem( i18n("Remove\ngroup") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( removeGroup() ) );
  menuItem = m_fanMenu->addItem( i18n("Add\ngroup") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( addGroup() ) );
  menuItem = m_fanMenu->addItem( i18n("Add\nperson") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( addPerson() ) );

  m_fanMenu->setupItems( 90 );

  setAcceptHoverEvents( true );
}
示例#17
0
bool CountTable::setNamesOfGroups(vector<string> mygroups) {
    try {
        //remove groups from table not in new groups we are setting
        for (int i = 0; i < groups.size(); i++) {
            if (m->inUsersGroups(groups[i], mygroups)) {}
            else { removeGroup(groups[i]);  }
        }
        
        //add any new groups in new groups list to table
        for (int i = 0; i < mygroups.size(); i++) {
            if (m->inUsersGroups(mygroups[i], groups)) {}
            else { addGroup(mygroups[i]);  }
        }
        
        //false if error
        return (!m->control_pressed);
    }
    catch(exception& e) {
        m->errorOut(e, "CountTable", "setNamesOfGroups");
        exit(1);
    }
}
void Ut_DBusInterfaceNotificationSink::testProxyCalledWhenServiceRegistered()
{
    Notification n;
    NotificationParameters np;

    sink->registerSink("service1", "path");
    QCOMPARE(gNewSinkProxies.count(), 1);

    emit addNotification(n);
    emit addGroup(0, np);
    emit removeNotification(0);
    emit removeGroup(0);

    QCOMPARE(gAddNotificationProxies.count(), 1);
    QCOMPARE(gAddNotificationProxies.at(0), gNewSinkProxies.at(0));
    QCOMPARE(gAddGroupProxies.count(), 1);
    QCOMPARE(gAddGroupProxies.at(0), gNewSinkProxies.at(0));
    QCOMPARE(gRemoveNotificationProxies.count(), 1);
    QCOMPARE(gRemoveNotificationProxies.at(0), gNewSinkProxies.at(0));
    QCOMPARE(gRemoveGroupProxies.count(), 1);
    QCOMPARE(gRemoveGroupProxies.at(0), gNewSinkProxies.at(0));
}
void CtrlrLuaMethodEditor::itemClicked (const MouseEvent &e, ValueTree &item)
{
	if (e.mods.isPopupMenu())
	{
		if ( item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup) )
		{
			PopupMenu m;
			m.addSectionHeader ("Group operations");
			m.addItem (1, "Add method");
			m.addItem (2, "Add files");
			m.addItem (3, "Add group");
			m.addSeparator();
			if (item.hasType (Ids::luaMethodGroup))
			{
				m.addItem (4, "Remove group");
				m.addItem (5, "Rename group");
			}

			m.addSeparator();
			m.addItem (6, "Sort by name");
			m.addItem (7, "Sort by size");

			const int ret = m.show();

			if (ret == 1)
			{
				addNewMethod (item);
			}
			else if (ret == 2)
			{
				addMethodFromFile (item);
			}
			else if (ret == 3)
			{
				addNewGroup (item);
			}
			else if (ret == 4)
			{
				removeGroup (item);
			}
			else if (ret == 5)
			{
				renameGroup (item);
			}
			else if (ret == 6)
			{
				ChildSorter sorter(true);
				getMethodManager().getManagerTree().sort (sorter, nullptr, false);

				triggerAsyncUpdate();
			}
			else if (ret == 7)
			{
				ChildSorter sorter(false);
				getMethodManager().getManagerTree().sort (sorter, nullptr, false);

				triggerAsyncUpdate();
			}
		}
		else if (item.hasType(Ids::luaMethod))
		{
			PopupMenu m;
			m.addSectionHeader ("Method " + item.getProperty(Ids::luaMethodName).toString());
			if ((int)item.getProperty(Ids::luaMethodSource) == CtrlrLuaMethod::codeInFile)
			{
				if (!File(item.getProperty(Ids::luaMethodSourcePath)).existsAsFile())
				{
					m.addItem (12, "Locate file on disk");
				}
			}

			m.addSeparator();
			m.addItem (2,"Remove method");

			const int ret = m.show();

			if (ret == 11)
			{
				/* convert a in-memory method to a file based one */
			}
			else if (ret == 12)
			{
				/* locate a missing file on disk */
			}
			else if (ret == 10)
			{
				/* convert a method from a file to a in-memory property */
			}
			else if (ret == 2)
			{
				/* remove a method */
				if (SURE("Delete the selected method?", this))
				{
					{
						methodEditArea->closeTabWithMethod (item);
						getMethodManager().removeMethod (item.getProperty(Ids::uuid).toString());
					}

					triggerAsyncUpdate();
				}
			}
		}
	}
}
QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* parent )
    : QDialog( parent ), mStyle( style ), mModified( false )
{
  setupUi( this );
#ifdef Q_OS_MAC
  setWindowModality( Qt::WindowModal );
#endif

  QSettings settings;
  restoreGeometry( settings.value( "/Windows/StyleV2Manager/geometry" ).toByteArray() );
  mSplitter->setSizes( QList<int>() << 170 << 540 );
  mSplitter->restoreState( settings.value( "/Windows/StyleV2Manager/splitter" ).toByteArray() );

  tabItemType->setDocumentMode( true );
  searchBox->setPlaceholderText( tr( "Type here to filter symbols..." ) );

  connect( this, SIGNAL( finished( int ) ), this, SLOT( onFinished() ) );

  connect( listItems, SIGNAL( doubleClicked( const QModelIndex & ) ), this, SLOT( editItem() ) );

  connect( btnAddItem, SIGNAL( clicked() ), this, SLOT( addItem() ) );
  connect( btnEditItem, SIGNAL( clicked() ), this, SLOT( editItem() ) );
  connect( btnRemoveItem, SIGNAL( clicked() ), this, SLOT( removeItem() ) );

  QMenu *shareMenu = new QMenu( tr( "Share Menu" ), this );
  QAction *exportAsPNGAction = shareMenu->addAction( tr( "Export as PNG" ) );
  QAction *exportAsSVGAction = shareMenu->addAction( tr( "Export as SVG" ) );
  QAction *exportAction = shareMenu->addAction( tr( "Export" ) );
  QAction *importAction = shareMenu->addAction( tr( "Import" ) );
  exportAsPNGAction->setIcon( QIcon( QgsApplication::iconPath( "mActionSharingExport.svg" ) ) );
  exportAsSVGAction->setIcon( QIcon( QgsApplication::iconPath( "mActionSharingExport.svg" ) ) );
  exportAction->setIcon( QIcon( QgsApplication::iconPath( "mActionSharingExport.svg" ) ) );
  importAction->setIcon( QIcon( QgsApplication::iconPath( "mActionSharingImport.svg" ) ) );
  connect( exportAsPNGAction, SIGNAL( triggered() ), this, SLOT( exportItemsPNG() ) );
  connect( exportAsSVGAction, SIGNAL( triggered() ), this, SLOT( exportItemsSVG() ) );
  connect( exportAction, SIGNAL( triggered() ), this, SLOT( exportItems() ) );
  connect( importAction, SIGNAL( triggered() ), this, SLOT( importItems() ) );
  btnShare->setMenu( shareMenu );

  // Set editing mode off by default
  mGrouppingMode = false;

  QStandardItemModel* model = new QStandardItemModel( listItems );
  listItems->setModel( model );
  listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );

  connect( model, SIGNAL( itemChanged( QStandardItem* ) ), this, SLOT( itemChanged( QStandardItem* ) ) );
  connect( listItems->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ),
           this, SLOT( symbolSelected( const QModelIndex& ) ) );

  populateTypes();

  QStandardItemModel* groupModel = new QStandardItemModel( groupTree );
  groupTree->setModel( groupModel );
  groupTree->setHeaderHidden( true );
  populateGroups();
  connect( groupTree->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ),
           this, SLOT( groupChanged( const QModelIndex& ) ) );
  connect( groupModel, SIGNAL( itemChanged( QStandardItem* ) ),
           this, SLOT( groupRenamed( QStandardItem* ) ) );

  QMenu *groupMenu = new QMenu( tr( "Group Actions" ), this );
  QAction *groupSymbols = groupMenu->addAction( tr( "Group Symbols" ) );
  QAction *editSmartgroup = groupMenu->addAction( tr( "Edit Smart Group" ) );
  btnManageGroups->setMenu( groupMenu );
  connect( groupSymbols, SIGNAL( triggered() ), this, SLOT( groupSymbolsAction() ) );
  connect( editSmartgroup, SIGNAL( triggered() ), this, SLOT( editSmartgroupAction() ) );

  connect( btnAddGroup, SIGNAL( clicked() ), this, SLOT( addGroup() ) );
  connect( btnRemoveGroup, SIGNAL( clicked() ), this, SLOT( removeGroup() ) );

  on_tabItemType_currentChanged( 0 );

  connect( searchBox, SIGNAL( textChanged( QString ) ), this, SLOT( filterSymbols( QString ) ) );
  tagsLineEdit->installEventFilter( this );

  // Context menu for groupTree
  groupTree->setContextMenuPolicy( Qt::CustomContextMenu );
  connect( groupTree, SIGNAL( customContextMenuRequested( const QPoint& ) ),
           this, SLOT( grouptreeContextMenu( const QPoint& ) ) );

  // Context menu for listItems
  listItems->setContextMenuPolicy( Qt::CustomContextMenu );
  connect( listItems, SIGNAL( customContextMenuRequested( const QPoint& ) ),
           this, SLOT( listitemsContextMenu( const QPoint& ) ) );

}
示例#21
0
int CountTable::createTable(string namefile, string groupfile, bool createGroup) {
    try {
        
        if (namefile == "") { m->mothurOut("[ERROR]: namefile cannot be blank when creating a count table.\n"); m->control_pressed = true; }
                                           
        GroupMap* groupMap;
        int numGroups = 0;
        groups.clear();
        totalGroups.clear();
        indexGroupMap.clear();
        indexNameMap.clear();
        counts.clear();
        map<int, string> originalGroupIndexes;
        
        if (groupfile != "") { 
            hasGroups = true;
            groupMap = new GroupMap(groupfile); groupMap->readMap();
            numGroups = groupMap->getNumGroups();
            groups = groupMap->getNamesOfGroups();
            totalGroups.resize(numGroups, 0);
        }else if(createGroup) {
            hasGroups = true;
            numGroups = 1;
            groups.push_back("Group1");
            totalGroups.resize(numGroups, 0);
        }
		//sort groups to keep consistent with how we store the groups in groupmap
        sort(groups.begin(), groups.end());
        for (int i = 0; i < groups.size(); i++) {  indexGroupMap[groups[i]] = i; }
        m->setAllGroups(groups);
        
        bool error = false;
        string name;
        uniques = 0;
        total = 0;
        
        
        //open input file
        ifstream in;
        m->openInputFile(namefile, in);
        
        int total = 0;
        while (!in.eof()) {
            if (m->control_pressed) { break; }
            
            string firstCol, secondCol;
            in >> firstCol; m->gobble(in); in >> secondCol; m->gobble(in);
            
            m->checkName(firstCol);
            m->checkName(secondCol);
            
            vector<string> names;
            m->splitAtChar(secondCol, names, ',');
            
            map<string, int> groupCounts;
            int thisTotal = 0;
            if (groupfile != "") {
                //set to 0
                for (int i = 0; i < groups.size(); i++) { groupCounts[groups[i]] = 0; }
                
                //get counts for each of the users groups
                for (int i = 0; i < names.size(); i++) {
                    string group = groupMap->getGroup(names[i]);
                    
                    if (group == "not found") { m->mothurOut("[ERROR]: " + names[i] + " is not in your groupfile, please correct."); m->mothurOutEndLine(); error=true; }
                    else {
                        map<string, int>::iterator it = groupCounts.find(group);
                        
                        //if not found, then this sequence is not from a group we care about
                        if (it != groupCounts.end()) {
                            it->second++;
                            thisTotal++;
                        }
                    }
                }
            }else if (createGroup) {
                groupCounts["Group1"]=0;
                for (int i = 0; i < names.size(); i++) {
                    string group = "Group1";
                    groupCounts["Group1"]++; thisTotal++;
                }
            }else { thisTotal = names.size();  }
            
            //if group info, then read it
            vector<int> thisGroupsCount; thisGroupsCount.resize(numGroups, 0);
            for (int i = 0; i < numGroups; i++) {  
                thisGroupsCount[i] = groupCounts[groups[i]]; 
                totalGroups[i] += thisGroupsCount[i]; 
            }
            
            map<string, int>::iterator it = indexNameMap.find(firstCol);
            if (it == indexNameMap.end()) {
                if (hasGroups) {  counts.push_back(thisGroupsCount);  }
                indexNameMap[firstCol] = uniques;
                totals.push_back(thisTotal);
                total += thisTotal;
                uniques++;
            }else {
                error = true;
                m->mothurOut("[ERROR]: Your count table contains more than 1 sequence named " + firstCol + ", sequence names must be unique. Please correct."); m->mothurOutEndLine(); 
            }
        }
        in.close();
		
        if (error) { m->control_pressed = true; }
        else { //check for zero groups
            if (hasGroups) {
                for (int i = 0; i < totalGroups.size(); i++) {
                    if (totalGroups[i] == 0) { m->mothurOut("\nRemoving group: " + groups[i] + " because all sequences have been removed.\n"); removeGroup(groups[i]); i--; }
                }
            }
        }
        if (groupfile != "") { delete groupMap; }
        
        return 0;
    }
	catch(exception& e) {
		m->errorOut(e, "CountTable", "createTable");
		exit(1);
	}
}
示例#22
0
void SettingsSerializer::readIni()
{
    QSettings s(path, QSettings::IniFormat);

    // Read all keys of all groups, reading arrays as raw keys
    QList<QString> gstack;
    do {
        // Add all keys
        if (!s.group().isEmpty())
            beginGroup(s.group());

        for (QString k : s.childKeys())
        {
            setValue(k, s.value(k));
        }

        // Add all groups
        gstack.push_back(QString());
        for (QString g : s.childGroups())
            gstack.push_back(g);

        // Visit the next group, if any
        while (!gstack.isEmpty())
        {
            QString g = gstack.takeLast();
            if (g.isEmpty())
            {
                if (gstack.isEmpty())
                    break;
                else
                    s.endGroup();
            }
            else
            {
                s.beginGroup(g);
                break;
            }
        }
    } while (!gstack.isEmpty());

    // We can convert keys that look like arrays into real arrays
    // If a group's only key is called size, we'll consider it to be an array,
    // and its elements are all groups matching the pattern "[<group>/]<arrayName>/<arrayIndex>"

    // Find groups that only have 1 key
    std::unique_ptr<int[]> groupSizes{new int[groups.size()]};
    memset(groupSizes.get(), 0, static_cast<size_t>(groups.size()) * sizeof(int));
    for (const Value& v : values)
    {
        if (v.group < 0 || v.group > groups.size())
            continue;
        groupSizes[static_cast<size_t>(v.group)]++;
    }

    // Find arrays, remove their size key from the values, and add them to `arrays`
    QVector<int> groupsToKill;
    for (int i=values.size()-1; i>=0; i--)
    {
        const Value& v = values[i];
        if (v.group < 0 || v.group > groups.size())
            continue;
        if (groupSizes[static_cast<size_t>(v.group)] != 1)
            continue;
        if (v.key != "size")
            continue;
        if (!v.value.canConvert(QVariant::Int))
            continue;

        Array a;
        a.size = v.value.toInt();
        int slashIndex = groups[static_cast<int>(v.group)].lastIndexOf('/');
        if (slashIndex == -1)
        {
            a.group = -1;
            a.name = groups[static_cast<int>(v.group)];
            a.size = v.value.toInt();
        }
        else
        {
            a.group = -1;
            for (int i=0; i<groups.size(); i++)
                if (groups[i] == groups[static_cast<int>(v.group)].left(slashIndex))
                    a.group = i;
            a.name = groups[static_cast<int>(v.group)].mid(slashIndex+1);

        }
        groupSizes[static_cast<size_t>(v.group)]--;
        groupsToKill.append(static_cast<int>(v.group));
        arrays.append(a);
        values.removeAt(i);
    }

    // Associate each array's values with the array
    for (int ai=0; ai<arrays.size(); ai++)
    {
        Array& a = arrays[ai];
        QString arrayPrefix;
        if (a.group != -1)
            arrayPrefix += groups[static_cast<int>(a.group)]+'/';
        arrayPrefix += a.name+'/';

        // Find groups which represent each array index
        for (int g=0; g<groups.size(); g++)
        {
            if (!groups[g].startsWith(arrayPrefix))
                continue;
            bool ok;
            int groupArrayIndex = groups[g].mid(arrayPrefix.size()).toInt(&ok);
            if (!ok)
                continue;
            groupsToKill.append(g);

            if (groupArrayIndex > a.size)
                a.size = groupArrayIndex;

            // Associate the values for this array index
            for (int vi = values.size() - 1; vi >= 0; vi--)
            {
                Value& v = values[vi];
                if (v.group != g)
                    continue;
                groupSizes[static_cast<size_t>(g)]--;
                v.group = a.group;
                v.array = ai;
                v.arrayIndex = groupArrayIndex;
                a.values.append(vi);
            }
        }
    }

    // Clean up spurious array element groups
    std::sort(std::begin(groupsToKill), std::end(groupsToKill),
         std::greater_equal<int>());

    for (int g : groupsToKill)
    {
        if (groupSizes[static_cast<size_t>(g)])
            continue;

        removeGroup(g);
    }

    group = array = -1;
}
示例#23
0
int CountTable::readTable(string file, bool readGroups, bool mothurRunning) {
    try {
        filename = file;
        ifstream in;
        m->openInputFile(filename, in);
        
        string headers = m->getline(in); m->gobble(in);
        vector<string> columnHeaders = m->splitWhiteSpace(headers);
        
        int numGroups = 0;
        groups.clear();
        totalGroups.clear();
        indexGroupMap.clear();
        indexNameMap.clear();
        counts.clear();
        map<int, string> originalGroupIndexes;
        if ((columnHeaders.size() > 2) && readGroups) { hasGroups = true; numGroups = columnHeaders.size() - 2;  }
        for (int i = 2; i < columnHeaders.size(); i++) {  groups.push_back(columnHeaders[i]);  originalGroupIndexes[i-2] = columnHeaders[i]; totalGroups.push_back(0); }
        //sort groups to keep consistent with how we store the groups in groupmap
        sort(groups.begin(), groups.end());
        for (int i = 0; i < groups.size(); i++) {  indexGroupMap[groups[i]] = i; }
        m->setAllGroups(groups);
        
        bool error = false;
        string name;
        int thisTotal;
        uniques = 0;
        total = 0;
        while (!in.eof()) {
            
            if (m->control_pressed) { break; }
            
            in >> name; m->gobble(in); in >> thisTotal; m->gobble(in);
            if (m->debug) { m->mothurOut("[DEBUG]: " + name + '\t' + toString(thisTotal) + "\n"); }
            
            if ((thisTotal == 0) && !mothurRunning) { error=true; m->mothurOut("[ERROR]: Your count table contains a sequence named " + name + " with a total=0. Please correct."); m->mothurOutEndLine();
            }
            
            //if group info, then read it
            vector<int> groupCounts; groupCounts.resize(numGroups, 0);
            if (columnHeaders.size() > 2) { //file contains groups
                if (readGroups) { //user wants to save them
                    for (int i = 0; i < numGroups; i++) {  int thisIndex = indexGroupMap[originalGroupIndexes[i]]; in >> groupCounts[thisIndex]; m->gobble(in); totalGroups[thisIndex] += groupCounts[thisIndex];  }
                }else { //read and discard
                    m->getline(in); m->gobble(in);
                }
            }
            
            map<string, int>::iterator it = indexNameMap.find(name);
            if (it == indexNameMap.end()) {
                if (hasGroups) {  counts.push_back(groupCounts);  }
                indexNameMap[name] = uniques;
                totals.push_back(thisTotal);
                total += thisTotal;
                uniques++;
            }else {
                error = true;
                m->mothurOut("[ERROR]: Your count table contains more than 1 sequence named " + name + ", sequence names must be unique. Please correct."); m->mothurOutEndLine(); 
            }
        }
        in.close();
        
        if (error) { m->control_pressed = true; }
        else { //check for zero groups
            if (hasGroups) {
                for (int i = 0; i < totalGroups.size(); i++) {
                    if (totalGroups[i] == 0) { m->mothurOut("\nRemoving group: " + groups[i] + " because all sequences have been removed.\n"); removeGroup(groups[i]); i--; }
                }
            }
        }
        
        return 0;
    }
示例#24
0
void Widget::removeGroup(int groupId)
{
    removeGroup(GroupList::findGroup(groupId));
}
示例#25
0
FiGroupWidget::FiGroupWidget(FClass* parent)
             : FWidget(parent, FUNC)
{
  mEditing = false;

  QPixmap icon(10, 10);

  mGroupView = new MyTableWidget(this);
  //mGroupView->setDragEnabled(false);
  //mGroupView->setAcceptDrops(false);
  mGroupView->setEditTriggers(QAbstractItemView::EditKeyPressed);

  connect(mGroupView, SIGNAL(currentRowChanged(int))
          , this, SLOT(groupRowChanged(int)));
  connect(mGroupView, SIGNAL(cellDoubleClicked(int, int))
          , this, SLOT(groupOpen(int, int)));
  connect(mGroupView, SIGNAL(cellChanged(int, int))
          , this, SLOT(groupEdited(int, int)));
  connect(mGroupView, SIGNAL(dragToNirvana())
          , this, SLOT(removeGroup()));

  mMotherName = new QLabel(this);
  //mMotherName->setWordWrap(true);
  mMotherName->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);

  QToolButton* btn = new QToolButton(this);
  btn->setAutoRaise(true);
  btn->setArrowType(Qt::UpArrow);
  btn->setToolTip("Up to Mother Group");
  connect(btn, SIGNAL(clicked(bool)), this, SLOT(groupUp()));

  QToolButton* newGroupBtn = new QToolButton(this);
  newGroupBtn->setAutoRaise(true);
  icon.fill(Qt::green);
  newGroupBtn->setIcon(icon);
  newGroupBtn->setToolTip("Add New Group");
  connect(newGroupBtn, SIGNAL(clicked(bool)), this, SLOT(newGroup()));

  //mMotherName->setAlignment(Qt::AlignVertical_Mask);
  //mMotherName->setOrientation(Qt::Vertical);
  QGridLayout* gbox = new QGridLayout;
  gbox->setMargin(0);
  gbox->addWidget(mMotherName, 0, 0);
  gbox->addWidget(newGroupBtn, 0, 1);
  gbox->addWidget(btn, 0, 2);
  gbox->addWidget(mGroupView, 1, 0, 1, 3);
  QWidget* gboxw = new QWidget;
  gboxw->setLayout(gbox);

  mMemberView = new MyTableWidget;

  connect( mMemberView, SIGNAL(currentRowChanged(int))
          , this, SLOT(memberRowChanged(int)));
  connect( mMemberView, SIGNAL(dragInFromTableView(QTableView*))
          , this, SLOT(userDragInData(QTableView*)));
  connect(mMemberView, SIGNAL(dragToNirvana())
          , this, SLOT(removeFromGroup()));

  mSplitter = new QSplitter(Qt::Vertical);
  //mSplitter->addWidget(mGroupView);
  mSplitter->addWidget(gboxw);
  mSplitter->addWidget(mMemberView);
  mSplitter->setStretchFactor(0, 1);
  mSplitter->setStretchFactor(1, 3);

  QGridLayout* layout = new QGridLayout;
  layout->setMargin(0);
  layout->addWidget(mSplitter, 0, 0);
  //layout->addWidget(, 0, 1);

  setLayout(layout);
}
示例#26
0
void FieldMap::removeGroup( int field )
{ QF_STACK_PUSH(FieldMap::removeGroup)
  removeGroup( groupCount(field), field );
  QF_STACK_POP
}
示例#27
0
文件: user.cpp 项目: codepr/linqedin
void ExecutiveUser::globalRemoveGroup(const LinqDB& db, const Group& g) {
    std::for_each(db.begin(), db.end(), RemoveGroup(const_cast<Group*> (&g)));
    removeGroup(g);
}
示例#28
0
int CountTable::createTable(set<string>& n, map<string, string>& g, set<string>& gs) {
    try {
        hasGroups = false;
        int numGroups = 0;
        groups.clear();
        totalGroups.clear();
        indexGroupMap.clear();
        indexNameMap.clear();
        counts.clear();
        for (set<string>::iterator it = gs.begin(); it != gs.end(); it++) { groups.push_back(*it);  hasGroups = true; }
        numGroups = groups.size();
        totalGroups.resize(numGroups, 0);
        
		//sort groups to keep consistent with how we store the groups in groupmap
        sort(groups.begin(), groups.end());
        for (int i = 0; i < groups.size(); i++) {  indexGroupMap[groups[i]] = i; }
        m->setAllGroups(groups);
        
        uniques = 0;
        total = 0;
        bool error = false;
        //n contains treenames
        for (set<string>::iterator it = n.begin(); it != n.end(); it++) {
            
            if (m->control_pressed) { break; }
            
            string seqName = *it;
            
            vector<int> groupCounts; groupCounts.resize(numGroups, 0);
            map<string, string>::iterator itGroup = g.find(seqName);
            
            if (itGroup != g.end()) {   
                groupCounts[indexGroupMap[itGroup->second]] = 1; 
                totalGroups[indexGroupMap[itGroup->second]]++;
            }else {
                //look for it in names of groups to see if the user accidently used the wrong file
                if (m->inUsersGroups(seqName, groups)) {
                    m->mothurOut("[WARNING]: Your group or design file contains a group named " + seqName + ".  Perhaps you are used a group file instead of a design file? A common cause of this is using a tree file that relates your groups (created by the tree.shared command) with a group file that assigns sequences to a group."); m->mothurOutEndLine();
                }
                m->mothurOut("[ERROR]: Your group file does not contain " + seqName + ". Please correct."); m->mothurOutEndLine();
            }
            
            map<string, int>::iterator it2 = indexNameMap.find(seqName);
            if (it2 == indexNameMap.end()) {
                if (hasGroups) {  counts.push_back(groupCounts);  }
                indexNameMap[seqName] = uniques;
                totals.push_back(1);
                total++;
                uniques++;
            }else {
                error = true;
                m->mothurOut("[ERROR]: Your count table contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();
            }

        }
        if (error) { m->control_pressed = true; }
        else { //check for zero groups
            if (hasGroups) {
                for (int i = 0; i < totalGroups.size(); i++) {
                    if (totalGroups[i] == 0) { m->mothurOut("\nRemoving group: " + groups[i] + " because all sequences have been removed.\n"); removeGroup(groups[i]); i--; }
                }
            }
        }
        return 0;
    }
	catch(exception& e) {
		m->errorOut(e, "CountTable", "createTable");
		exit(1);
	}
}