void LBMStreamDialogInfo::processPacket(const packet_info * pinfo, const lbm_uim_stream_tap_info_t * stream_info)
{
    LBMStreamEntry * stream = NULL;
    LBMStreamMapIterator it;

    it = m_streams.find(stream_info->channel);
    if (m_streams.end() == it)
    {
        QTreeWidgetItem * item = NULL;
        QTreeWidgetItem * parent = NULL;
        Ui::LBMStreamDialog * ui = NULL;

        stream = new LBMStreamEntry(pinfo, stream_info->channel, &(stream_info->endpoint_a), &(stream_info->endpoint_b));
        it = m_streams.insert(stream_info->channel, stream);
        item = new QTreeWidgetItem();
        stream->setItem(item);
        ui = m_dialog->getUI();
        ui->lbm_stream_TreeWidget->addTopLevelItem(item);
        parent = ui->lbm_stream_TreeWidget->invisibleRootItem();
        parent->sortChildren(Stream_Column, Qt::AscendingOrder);
    }
    else
    {
        stream = it.value();
    }
    stream->processPacket(pinfo, stream_info);
}
void PropertySelectionTreeWidget::addProcessorNetwork(ProcessorNetwork* processorNetwork, std::string workspaceFileName) {
    std::vector<Processor*> processors = processorNetwork->getProcessors();
    QTreeWidgetItem* worksapceItem = new QTreeWidgetItem(QStringList(QString::fromStdString(workspaceFileName)));

    if (processors.size())
        propertySelectionTree_->addTopLevelItem(worksapceItem);
    else {
        LogWarn("Empty workpace with no processors" << workspaceFileName);
        return;
    }

    for (auto& processor : processors) {
        std::vector<Property*> properties = processor->getProperties();
        std::string processorId = processor->getIdentifier();
        QTreeWidgetItem* processorItem = new QTreeWidgetItem(QStringList(QString::fromStdString(processorId)));
        worksapceItem->addChild(processorItem);

        for (auto& propertie : properties) {
            std::string id = propertie->getIdentifier();
            QTreeWidgetItem* newItem = new QTreeWidgetItem(QStringList(QString::fromStdString(id)));
            processorItem->addChild(newItem);
            newItem->setFlags(newItem->flags() | Qt::ItemIsUserCheckable);
            newItem->setCheckState(0, Qt::Unchecked);
        }

        propertySelectionTree_->addTopLevelItem(processorItem);
        processorItem->sortChildren(0, Qt::AscendingOrder);
    }

    propertySelectionTree_->expandAll();
}
void LBMStreamEntry::processPacket(const packet_info * pinfo, const lbm_uim_stream_tap_info_t * stream_info)
{
    LBMSubstreamEntry * substream = NULL;
    LBMSubstreamMapIterator it;

    if (m_first_frame > pinfo->num)
    {
        m_first_frame = pinfo->num;
    }
    if (m_flast_frame < pinfo->num)
    {
        m_flast_frame = pinfo->num;
    }
    m_bytes += stream_info->bytes;
    m_messages++;
    it = m_substreams.find(stream_info->substream_id);
    if (m_substreams.end() == it)
    {
        QTreeWidgetItem * item = NULL;

        substream = new LBMSubstreamEntry(m_channel, stream_info->substream_id, &(pinfo->src), pinfo->srcport, &(pinfo->dst), pinfo->destport);
        m_substreams.insert(stream_info->substream_id, substream);
        item = new QTreeWidgetItem();
        substream->setItem(item);
        m_item->addChild(item);
        m_item->sortChildren(Stream_Column, Qt::AscendingOrder);
    }
    else
    {
        substream = it.value();
    }
    fillItem();
    substream->processPacket(pinfo->num, stream_info->bytes);
}
CWizCategoryViewFolderItem* CWizFolderView::findFolder(const QString& strLocation, bool create, bool sort)
{
    CWizCategoryViewAllFoldersItem* pAllFolders = findAllFolders();
    if (!pAllFolders)
        return NULL;

    if (m_dbMgr.db().IsInDeletedItems(strLocation)) {
        return findTrash(m_dbMgr.db().kbGUID());
    }

    QString strCurrentLocation = "/";
    QTreeWidgetItem* parent = pAllFolders;

    CString strTempLocation = strLocation;
    strTempLocation.Trim('/');
    QStringList sl = strTempLocation.split("/");

    QStringList::const_iterator it;
    for (it = sl.begin(); it != sl.end(); it++) {
        QString strLocationName = *it;
        Q_ASSERT(!strLocationName.isEmpty());
        strCurrentLocation = strCurrentLocation + strLocationName + "/";

        bool found = false;
        int nCount = parent->childCount();
        for (int i = 0; i < nCount; i++)
        {
            CWizCategoryViewFolderItem* pFolder = dynamic_cast<CWizCategoryViewFolderItem*>(parent->child(i));
            if (pFolder
                && pFolder->name() == strLocationName)
            {
                found = true;
                parent = pFolder;
                continue;
            }
        }

        if (found)
            continue;

        if (!create)
            return NULL;

        CWizCategoryViewFolderItem* pFolderItem = new CWizCategoryViewFolderItem(m_app, strCurrentLocation, m_dbMgr.db().kbGUID());
        parent->addChild(pFolderItem);
        parent->setExpanded(true);
        if (sort)
        {
            parent->sortChildren(0, Qt::AscendingOrder);
        }

        parent = pFolderItem;
    }

    return dynamic_cast<CWizCategoryViewFolderItem *>(parent);
}
QTreeWidgetItem *CollectionTreeWidget::addAlbum(QString artist, QString album, unsigned int albumId) {
    // Find id in database if we don't have it
    if (albumId == 0) {
         QSqlTableModel *model = service->collectionModel();

         // SQLite used two single quotes to escape a single quote! :)
         QString filter = "artist = '" + QString(artist).replace("'","''") + "' AND "
                          "album = '" + QString(album).replace("'","''") + "'";
         model->setFilter(filter);
         model->select();

         while (model->canFetchMore()) model->fetchMore();
         int total = model->rowCount();
         if (total > 0) {
            albumId = model->record(0).value(model->fieldIndex("id_album")).toInt();
         }
         else {
             qDebug("ERROR: no album found! -- " + model->filter().toUtf8());
             return NULL;
         }
    }

    // Looks for the artist
    QTreeWidgetItem *newAlbumNode; // The node with the album, whether it exists or not
    QTreeWidgetItem *artistItem;
    artistItem = addArtist(artist);

    // Look for album
    for (int i = 0; i < artistItem->childCount(); i++) {
        if (artistItem->child(i)->text(0) == album) {
            newAlbumNode = artistItem->child(i);
            return newAlbumNode;
        }
    }

    // Create our new album node and add it if it was not found
    newAlbumNode = new CollectionTreeWidgetItem(LevelAlbum, albumId, (QTreeWidget*)0);
    newAlbumNode->setText(0, album);
    newAlbumNode->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);

    // Set icon
    newAlbumNode->setIcon(0, IconFactory::fromTheme("media-cdrom"));

    artistItem->addChild(newAlbumNode);
    artistItem->sortChildren(0, Qt::AscendingOrder);

    return newAlbumNode;
}
Example #6
0
void VSCDeviceList::AddDisk(astring strTitle)
{
    QTreeWidgetItem *qtreewidgetitem = ui.treeWidget->topLevelItem(VSC_DEVICE_INDEX_DSIK);
    QIcon icon1;
    icon1.addFile(QStringLiteral(":/device/resources/harddisk.png"), QSize(), QIcon::Normal, QIcon::Off);
    //icon1.addFile(QStringLiteral(":/device/resources/camera-record.png"), QSize(), QIcon::Normal, QIcon::Off);

    QTreeWidgetItem *qtreewidgetitemChild = new QTreeWidgetItem(qtreewidgetitem);

    qtreewidgetitemChild->setIcon(0, icon1);

    qtreewidgetitemChild->setText(0, QApplication::translate("Disk",  strTitle.c_str(), 0));

    qtreewidgetitem->setExpanded(true);
    qtreewidgetitem->sortChildren(0, Qt::AscendingOrder);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_sort_children (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) {

         if (Args.Length () > 1) {

            item->sortChildren (
               v8_to_uint32 (Args[0]),
               (Qt::SortOrder)v8_to_uint32 (Args[1]));
         }
      }
   }

   return scope.Close (result);
}
Example #8
0
void lmcChatRoomWindow::updateUser(User* pUser) {
	if(!pUser)
		return;

	QTreeWidgetItem* pItem = getUserItem(&pUser->id);
	if(pItem) {
		updateStatusImage(pItem, &pUser->status);
		pItem->setData(0, StatusRole, Helper::statusIndexFromCode(pUser->status));
		pItem->setData(0, SubtextRole, pUser->note);
		pItem->setText(0, pUser->name);
		QTreeWidgetItem* pGroupItem = pItem->parent();
		pGroupItem->sortChildren(0, Qt::AscendingOrder);
	}

	if(groupMode)
		setWindowTitle(getWindowTitle());

	//	Local user cannot participate in public chat if status is offline
	if(!groupMode && pUser->id.compare(localId) == 0) {
		bool offline = (statusType[Helper::statusIndexFromCode(pUser->status)] == StatusTypeOffline);
		ui.txtMessage->setEnabled(!offline);
		ui.txtMessage->setFocus();
	}
}
Example #9
0
SettingsDialog::SettingsDialog(Application* app, BackgroundStreams* streams,
                               QWidget* parent)
    : QDialog(parent),
      app_(app),
      model_(app_->library_model()->directory_model()),
      gst_engine_(qobject_cast<GstEngine*>(app_->player()->engine())),
      song_info_view_(nullptr),
      streams_(streams),
      global_search_(app_->global_search()),
      appearance_(app_->appearance()),
      ui_(new Ui_SettingsDialog),
      loading_settings_(false) {
  ui_->setupUi(this);
  ui_->list->setItemDelegate(new SettingsItemDelegate(this));

  QTreeWidgetItem* general = AddCategory(tr("General"));

  AddPage(Page_Playback, new PlaybackSettingsPage(this), general);
  AddPage(Page_Behaviour, new BehaviourSettingsPage(this), general);
  AddPage(Page_Library, new LibrarySettingsPage(this), general);
  AddPage(Page_Proxy, new NetworkProxySettingsPage(this), general);
  AddPage(Page_Transcoding, new TranscoderSettingsPage(this), general);
  AddPage(Page_NetworkRemote, new NetworkRemoteSettingsPage(this), general);

#ifdef HAVE_WIIMOTEDEV
  AddPage(Page_Wiimotedev, new WiimoteSettingsPage(this), general);
#endif

  // User interface
  QTreeWidgetItem* iface = AddCategory(tr("User interface"));
  AddPage(Page_GlobalShortcuts, new GlobalShortcutsSettingsPage(this), iface);
  AddPage(Page_GlobalSearch, new GlobalSearchSettingsPage(this), iface);
  AddPage(Page_Appearance, new AppearanceSettingsPage(this), iface);
  AddPage(Page_SongInformation, new SongInfoSettingsPage(this), iface);
  AddPage(Page_Notifications, new NotificationsSettingsPage(this), iface);

  // Internet providers
  QTreeWidgetItem* providers = AddCategory(tr("Internet providers"));

#ifdef HAVE_LIBLASTFM
  AddPage(Page_Lastfm, new LastFMSettingsPage(this), providers);
#endif

  AddPage(Page_Grooveshark, new GroovesharkSettingsPage(this), providers);

#ifdef HAVE_GOOGLE_DRIVE
  AddPage(Page_GoogleDrive, new GoogleDriveSettingsPage(this), providers);
#endif

#ifdef HAVE_DROPBOX
  AddPage(Page_Dropbox, new DropboxSettingsPage(this), providers);
#endif

#ifdef HAVE_BOX
  AddPage(Page_Box, new BoxSettingsPage(this), providers);
#endif

#ifdef HAVE_SKYDRIVE
  AddPage(Page_Skydrive, new SkydriveSettingsPage(this), providers);
#endif

  AddPage(Page_SoundCloud, new SoundCloudSettingsPage(this), providers);
  AddPage(Page_Spotify, new SpotifySettingsPage(this), providers);

#ifdef HAVE_VK
  AddPage(Page_Vk, new VkSettingsPage(this), providers);
#endif

#ifdef HAVE_SEAFILE
  AddPage(Page_Seafile, new SeafileSettingsPage(this), providers);
#endif



  AddPage(Page_Magnatune, new MagnatuneSettingsPage(this), providers);
  AddPage(Page_DigitallyImported, new DigitallyImportedSettingsPage(this),
          providers);
  AddPage(Page_BackgroundStreams, new BackgroundStreamsSettingsPage(this),
          providers);
  AddPage(Page_Subsonic, new SubsonicSettingsPage(this), providers);
  AddPage(Page_Podcasts, new PodcastSettingsPage(this), providers);

  providers->sortChildren(0, Qt::AscendingOrder);

  // List box
  connect(ui_->list,
          SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
          SLOT(CurrentItemChanged(QTreeWidgetItem*)));
  ui_->list->setCurrentItem(pages_[Page_Playback].item_);

  // Make sure the list is big enough to show all the items
  ui_->list->setMinimumWidth(
      static_cast<QAbstractItemView*>(ui_->list)->sizeHintForColumn(0));

  ui_->buttonBox->button(QDialogButtonBox::Cancel)
      ->setShortcut(QKeySequence::Close);
}
Example #10
0
void ChannelsJoinDialog::fillListView()
{
	m_pTreeWidget->clear();

	m_pTreeWidget->header()->hide();

	// Registered channels go first

	QTreeWidgetItem * par = new QTreeWidgetItem(m_pTreeWidget, HeaderItem);
	par->setText(0,__tr2qs("Registered Channels"));
	par->setExpanded(true);

	QHash<QString,KviRegisteredChannelList *> * d = g_pRegisteredChannelDataBase->channelDict();
	if(d)
	{
		for(QHash<QString,KviRegisteredChannelList *>::Iterator it = d->begin();it != d->end();++it)
		{
			QTreeWidgetItem * chld = new QTreeWidgetItem(par, RegisteredChannelItem);
			chld->setText(0,it.key());
			chld->setIcon(0,*(g_pIconManager->getSmallIcon(KviIconManager::Channel)));
		}
	}

	par->sortChildren(0, Qt::AscendingOrder);

	par = new QTreeWidgetItem(m_pTreeWidget, HeaderItem);
	par->setText(0,__tr2qs("Recent Channels"));
	par->setExpanded(true);

	QTreeWidgetItem * chld;

	bool bGotChanOnCurrentNetwork = false;

	QTreeWidgetItem * hdr;

	if(m_pConsole)
	{
		QStringList * pList = g_pApp->recentChannelsForNetwork(m_pConsole->currentNetworkName());
		if(pList)
		{
			if(pList->count() > 0)
			{
				bGotChanOnCurrentNetwork = true;

				hdr = new QTreeWidgetItem(par, HeaderItem);
				hdr->setText(0,__tr2qs("Current Network"));
				hdr->setExpanded(true);

				for(QStringList::Iterator it = pList->begin(); it != pList->end(); ++it)
				{
					chld = new QTreeWidgetItem(hdr, RecentChannelItem);
					chld->setText(0,*it);
					chld->setIcon(0,*(g_pIconManager->getSmallIcon(KviIconManager::Channel)));
				}
				hdr->sortChildren(0, Qt::AscendingOrder);
			}
		}
	}

	KviPointerHashTable<QString,QStringList> * pDict = g_pApp->recentChannels();
	if(!pDict)
		return;

	hdr = new QTreeWidgetItem(par, HeaderItem);
	hdr->setText(0,__tr2qs("All Networks"));

	if(!bGotChanOnCurrentNetwork)
		hdr->setExpanded(true); // expand this one instead

	QHash<QString,int> hNoDuplicates;

	for(QStringList * pChans = pDict->first();pChans;pChans = pDict->next())
	{
		for(QStringList::Iterator it = pChans->begin(); it != pChans->end(); ++it)
		{
			QString chan = *it;
			if(hNoDuplicates.contains(chan.toLower()))
				continue;
			hNoDuplicates.insert(chan.toLower(),1);
			chld = new QTreeWidgetItem(hdr, RecentChannelItem);
			chld->setText(0,chan);
			chld->setIcon(0,*(g_pIconManager->getSmallIcon(KviIconManager::Channel)));
		}
	}
	hdr->sortChildren(0, Qt::AscendingOrder);
}
Example #11
0
int Gitarre::StatusCb (const char *path, unsigned int status_flags, int i, StatusCbMode mode)
{
	if (mode == Gitarre::Add || ( mode == Gitarre::Update && ( (status_flags & GIT_STATUS_WT_NEW) || (status_flags & GIT_STATUS_WT_DELETED) )))
	{
		Repository *repo = Repos[i];
		git_repository *gitRepo = repo->GetGitRepo();
		QString repoPath = repo->GetPath();
		QString relPath (path);
		// Split path into hierarchy
		QStringList hier = relPath.split ("/");

		// For every hierarchy member, check whether directory exists and was added to RepoView
		QString absoluteDirPath = repoPath;
		QTreeWidgetItem *item = RepoView->topLevelItem(i);
		for (int j = 0; j < hier.size() - 1; ++j)
		{
			absoluteDirPath += QString ('/') + hier[j];
			QTreeWidgetItem *foundItem = findChildItem (item, hier[j]);
			if (!foundItem)
			{
				foundItem = new QTreeWidgetItem (QStringList (hier[j]));
				foundItem->setIcon (0, QIcon::fromTheme ("folder"));
				QDir absoluteDir (absoluteDirPath);
				if (!absoluteDir.exists())
					foundItem->setForeground(0, QBrush (ColorDeleted));
				else
				{
					// TODO: This is not working for some reason; find alternative way to address (maybe via .gitignore directly?)
					int ignored;
					git_status_should_ignore (&ignored, gitRepo, absoluteDirPath.toStdString().c_str());
					if (ignored)
						foundItem->setForeground(0, QBrush (ColorIgnored));
				}
				item->addChild(foundItem);
			}
			item = foundItem;
		}
		if (mode == Gitarre::Add || ( mode == Gitarre::Update && !(status_flags & GIT_STATUS_WT_DELETED)))
		{
			QTreeWidgetItem *child = NULL;
			if (mode == Gitarre::Update)
			{
				child = findChildItem (item, hier.back());
			}
			if (!child)
			{
				QTreeWidgetItem *child = new QTreeWidgetItem (QStringList (hier.back()));
				child->setIcon(0, QIcon::fromTheme ("text-x-generic"));
				if (status_flags & GIT_STATUS_IGNORED)
					child->setForeground(0, QBrush (ColorIgnored));
				else if (status_flags & GIT_STATUS_WT_DELETED)
					child->setForeground(0, QBrush (ColorDeleted));
				else if (status_flags & GIT_STATUS_WT_NEW)
					child->setForeground(0, QBrush (ColorNew));
				item->addChild(child);
				if (mode == Gitarre::Update)
					item->sortChildren(0, Qt::AscendingOrder);
			}
		}
		else			// only option is mode == Gitarre::Update && status_flags & GIT_STATUS_WT_DELETED
		{
			QTreeWidgetItem *child = findChildItem (item, hier.back());
			if (!child)
			{
				QTreeWidgetItem *child = new QTreeWidgetItem (QStringList (hier.back()));
				child->setIcon(0, QIcon::fromTheme ("text-x-generic"));
				item->addChild(child);
				item->sortChildren(0, Qt::AscendingOrder);
			}
			child->setForeground(0, QBrush (ColorDeleted));
		}
	}
	return 0;
}
Example #12
0
void QTreeWidgetItemProto::sortChildren(int column, int order)
{
  QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject());
  if (item)
    item->sortChildren(column, (Qt::SortOrder)order);
}
Example #13
-2
void AddFixture::fillTree(const QString& selectManufacturer,
                          const QString& selectModel)
{
    QTreeWidgetItem* parent = NULL;
    QTreeWidgetItem* child;
    QString manuf;
    QString model;
    QList<QVariant> expanded;

    QSettings settings;
    QVariant var = settings.value(SETTINGS_EXPANDED);
    if (var.isValid() == true)
    {
        expanded = var.toList();
    }

    /* Clear the tree of any previous data */
    m_tree->clear();

    QString filter = m_searchEdit->text().toLower();

    /* Add all known fixture definitions to the tree */
    QStringListIterator it(m_doc->fixtureDefCache()->manufacturers());
    while (it.hasNext() == true)
    {
        bool manufAdded = false;

        manuf = it.next();
        if (manuf == KXMLFixtureGeneric)
            continue;

        QStringListIterator modit(m_doc->fixtureDefCache()->models(manuf));
        while (modit.hasNext() == true)
        {
            model = modit.next();

            if (filter.isEmpty() == false &&
                manuf.toLower().contains(filter) == false &&
                model.toLower().contains(filter) == false)
                    continue;

            if (manufAdded == false)
            {
                parent = new QTreeWidgetItem(m_tree);
                parent->setText(KColumnName, manuf);
                manufAdded = true;
            }
            child = new QTreeWidgetItem(parent);
            child->setText(KColumnName, model);

            if (manuf == selectManufacturer &&
                    model == selectModel)
            {
                parent->setExpanded(true);
                m_tree->setCurrentItem(child);
            }
            else if(expanded.indexOf(manuf) != -1)
            {
                parent->setExpanded(true);
            }
            m_fxiCount++;
        }
    }

    /* Sort the tree A-Z BEFORE appending a generic entries */
    m_tree->sortItems(0, Qt::AscendingOrder);

    /* Create a parent for the generic devices */
    parent = new QTreeWidgetItem(m_tree);
    parent->setText(KColumnName, KXMLFixtureGeneric);
    QStringListIterator modit(m_doc->fixtureDefCache()->models(KXMLFixtureGeneric));
    while (modit.hasNext() == true)
    {
        model = modit.next();
        child = new QTreeWidgetItem(parent);
        child->setText(KColumnName, model);

        if (selectManufacturer == KXMLFixtureGeneric &&
                model == selectModel)
        {
            parent->setExpanded(true);
            m_tree->setCurrentItem(child);
        }
        else if(expanded.indexOf(manuf) != -1)
        {
            parent->setExpanded(true);
        }
        m_fxiCount++;
    }

    /* Create a child for generic dimmer device */
    child = new QTreeWidgetItem(parent);
    child->setText(KColumnName, KXMLFixtureGeneric);

    parent->sortChildren(0, Qt::AscendingOrder);

    /* Select generic dimmer by default */
    if (selectManufacturer == KXMLFixtureGeneric &&
            selectModel == KXMLFixtureGeneric)
    {
        parent->setExpanded(true);
        m_tree->setCurrentItem(child);
    }
}