Пример #1
0
void OptionTree::
init_Applets()
{
	cout << "OptionTree: initializing setup applets\n";

	QListViewItem *item;


	item = new QListViewItem( w_tree , i18n("File Options") );
	item->sortChildItems( 0 , true );
	item->setOpen(true);
	(void) new QListViewItem( item , i18n("Nmap path") );
	(void) new QListViewItem( item , i18n("Logging") );

	item = new QListViewItem( w_tree , i18n("Scan Options") );
	item->sortChildItems( 0 , true );
	item->setOpen(true);
	(void) new QListViewItem( item , i18n("Miscellaneous") );
	(void) new QListViewItem( item , i18n("Stealth") );
	(void) new QListViewItem( item , i18n("Setup decoys") );
	(void) new QListViewItem( item , i18n("Setup pings") );
	(void) new QListViewItem( item , i18n("Scan type") );

	item = new QListViewItem( w_tree , i18n("Recent args") );
	item = new QListViewItem( w_tree , i18n("Recent hosts") );

	cout << "OptionTree: applet names initialized\n";
}
Пример #2
0
void DirectoryView::setDir( const QString &s )
{
  QListViewItemIterator it( this );
  ++it;
  for ( ; it.current(); ++it ) {
    it.current()->setOpen( false );
  }

  QStringList lst( QStringList::split( "/", s ) );
  QListViewItem *item = firstChild();
  QStringList::Iterator it2 = lst.begin();
  for ( ; it2 != lst.end(); ++it2 ) {
    while ( item ) {
      if ( item->text( 0 ) == *it2 ) {
        item->setOpen( true );
        break;
      }
      item = item->itemBelow();
    }
  }

  if ( item ){
    setSelected( item, true );
    setCurrentItem( item );
  }
}
Пример #3
0
bool ListViewItemDrag::decode( QDropEvent * event, QListView * parent, QListViewItem * insertPoint, DropRelation dr )
{
    QByteArray data = event->encodedData( "qt/listviewitem" );
    QListViewItem* itemParent = insertPoint ? insertPoint->parent() : 0;

    // Change from sibling (default) to child creation
    if ( insertPoint && dr == Child ) {
	itemParent = insertPoint;
	insertPoint = 0;
    }

    if ( data.size() ) {
	event->accept();
	QDataStream stream( data, IO_ReadOnly );

	int count = 0;
	stream >> count;

	for( int i = 0; i < count; i++ ) {
	    if ( itemParent ) {
		insertPoint = new QListViewItem( itemParent, insertPoint );
		itemParent->setOpen( TRUE );
	    } else { // No parent for insertPoint, use QListView
		insertPoint = new QListViewItem( parent, insertPoint );
	    }
	    stream >> *insertPoint;
	}
	return TRUE;
    }
Пример #4
0
void formatPropertySet( KTNEFPropertySet *pSet, QListView *lv )
{
	formatProperties( pSet->properties(), lv, 0, "prop" );
	QListViewItem *item = new QListViewItem( lv, i18n( "TNEF Attributes" ) );
	item->setOpen( true );
	formatProperties( pSet->attributes(), 0, item, "attr" );
}
Пример #5
0
void formatProperties( const QMap<int,KTNEFProperty*>& props, QListView *lv, QListViewItem *item, const QString& prefix )
{
	for ( QMap<int,KTNEFProperty*>::ConstIterator it=props.begin(); it!=props.end(); ++it )
	{
		QListViewItem *newItem = 0;
		if ( lv )
			newItem = new QListViewItem( lv, ( *it )->keyString() );
		else if ( item )
			newItem = new QListViewItem( item, ( *it )->keyString() );
		else
		{
			kdWarning() << "formatProperties() called with no listview and no item" << endl;
			return;
		}

		QVariant value = ( *it )->value();
		if ( value.type() == QVariant::List )
		{
			newItem->setOpen( true );
			newItem->setText( 0, newItem->text( 0 ) + " [" + QString::number( value.asList().count() ) + "]" );
			int i = 0;
			for ( QValueList<QVariant>::ConstIterator lit=value.listBegin(); lit!=value.listEnd(); ++lit, i++ )
				new QListViewItem( newItem, "[" + QString::number( i ) + "]", KTNEFProperty::formatValue( *lit ) );
		}
		else if ( value.type() == QVariant::DateTime )
			newItem->setText( 1, value.asDateTime().toString() );
		else
		{
			newItem->setText( 1, ( *it )->valueString() );
			newItem->setText( 2, prefix + "_" + QString::number( it.key() ) );
		}
	}
}
Пример #6
0
void RefactoringAssistant::refactor( UMLClassifier *obj )
{
    clear();
    m_umlObjectMap.clear();
    m_umlObject = obj;
    if (! m_umlObject )
    {
        return;
    }

    addClassifier( obj, 0, true, true, true );
    QListViewItem *item = firstChild();
    item->setOpen(true);
    for( item = item->firstChild(); item ; item = item->nextSibling() )
        item->setOpen(true);
}
Пример #7
0
void USBViewer::refresh()
{
    QIntDict< QListViewItem > new_items;

    if(!USBDevice::parse("/proc/bus/usb/devices"))
        USBDevice::parseSys("/sys/bus/usb/devices");

    int level = 0;
    bool found = true;

    while(found)
    {
        found = false;

        QPtrListIterator< USBDevice > it(USBDevice::devices());
        for(; it.current(); ++it)
            if(it.current()->level() == level)
            {
                Q_UINT32 k = key(*it.current());
                if(level == 0)
                {
                    QListViewItem *item = _items.find(k);
                    if(!item)
                    {
                        item = new QListViewItem(_devices, it.current()->product(), QString::number(k));
                    }
                    new_items.insert(k, item);
                    found = true;
                }
                else
                {
                    QListViewItem *parent = new_items.find(key_parent(*it.current()));
                    if(parent)
                    {
                        QListViewItem *item = _items.find(k);

                        if(!item)
                        {
                            item = new QListViewItem(parent, it.current()->product(), QString::number(k));
                        }
                        new_items.insert(k, item);
                        parent->setOpen(true);
                        found = true;
                    }
                }
            }

        ++level;
    }

    // recursive delete all items not in new_items
    delete_recursive(_devices->firstChild(), new_items);

    _items = new_items;

    if(!_devices->selectedItem())
        selectionChanged(_devices->firstChild());
}
Пример #8
0
void RosterBox::addGroup( QString name, bool open )
{
	QListViewItem *group = new QListViewItem( this, name, "group", name );
	
	if( open )
		group->setPixmap( 0, takePixmap( "group_open" ) );
	else
		group->setPixmap( 0, takePixmap( "group_closed" ) );
	openGroups[ name ] = open;
	group->setOpen( open );
	
	groupList.append( group );
}
Пример #9
0
void NewDevice::fillTree()
{
    QListViewItem* parent = NULL;
    QListViewItem* newItem = NULL;

    QPtrList <DeviceClass> *dl = _app->deviceClassList();

    QPixmap pm(PIXMAPS + QString("/dmx.xpm"));

    QString config;
    bool treeOpen = false;
    if (_app->settings()->get("NewDeviceTreeOpen", config) != -1 &&
            config == Settings::trueValue())
    {
        treeOpen = true;
    }
    else
    {
        treeOpen = false;
    }

    m_tree->clear();

    for (DeviceClass* dc = dl->first(); dc != NULL; dc = dl->next())
    {
        bool alreadyAdded = false;

        for (QListViewItem* i = m_tree->firstChild();
                i != NULL; i = i->nextSibling())
        {
            if (i->text(0) == dc->manufacturer())
            {
                alreadyAdded = true;
                parent = i;
                break;
            }
        }

        if (alreadyAdded == false)
        {
            parent = new QListViewItem(m_tree, dc->manufacturer());
            parent->setOpen(treeOpen);
        }

        parent->setPixmap(0, QPixmap(PIXMAPS + QString("/global.xpm")));

        newItem = new QListViewItem(parent, dc->model());
        newItem->setPixmap(0, pm);
        newItem->setText(1,dc->type());
    }
}
Пример #10
0
void ListViewEditor::itemNewSubClicked()
{
    QListViewItem *parent = itemsPreview->currentItem();
    QListViewItem *item = 0;
    if ( parent ) {
	item = new QListViewItem( parent );
	parent->setOpen( true );
    } else {
	item = new QListViewItem( itemsPreview );
    }
    item->setText( 0, "Subitem" );
    itemsPreview->setCurrentItem( item );
    itemsPreview->setSelected( item, true );
}
Пример #11
0
void CertificateInfoWidgetImpl::updateChainView() {
  pathView->clear();
  if ( mChain.empty() )
    return;
  QListViewItem * item = 0;

  QValueList<GpgME::Key>::const_iterator it = mChain.begin();
  // root item:
  if ( (*it).chainID() && qstrcmp( (*it).chainID(), (*it).primaryFingerprint() ) == 0 )
    item = new QListViewItem( pathView, Kleo::DN( (*it++).userID(0).id() ).prettyDN() );
  else {
    item = new QListViewItem( pathView, i18n("Issuer certificate not found ( %1)")
			      .arg( Kleo::DN( (*it).issuerName() ).prettyDN() ) );
    item->setOpen( true ); // Qt bug: doesn't open after setEnabled( false ) :/
    item->setEnabled( false );
  }
  item->setOpen( true );

  // subsequent items:
  while ( it != mChain.end() ) {
    item = new QListViewItem( item, Kleo::DN( (*it++).userID(0).id() ).prettyDN() );
    item->setOpen( true );
  }
}
Пример #12
0
void ActionConfigDialog::slotEditToolbar()
{
  QString toolbarName;
  QString toolbarId;
  QListViewItem *oldItem;
  QListViewItem *item = actionTreeView->currentItem();
  if (item->parent())
     item = item->parent();
  toolbarName = item->text(0);
  if ( toolbarName != i18n("All"))
  {
    emit configureToolbars(toolbarName +" <quanta>");

    //update the tree view
    KAction *action;
    KActionCollection *ac = m_mainWindow->actionCollection();
    ToolbarTabWidget *tb = ToolbarTabWidget::ref();
    for (int i = 0; i < tb->count(); i++)
    {
      toolbarName = tb->label(i);
      toolbarId = tb->id(i);
      ToolbarEntry *p_toolbar = m_toolbarList[toolbarId];
      if (p_toolbar)
      {
        oldItem = actionTreeView->findItem(toolbarName, 0);
        item = new KListViewItem(actionTreeView, oldItem, toolbarName);
        item->setOpen(oldItem->isOpen());
        delete oldItem;
        QDomNode node = p_toolbar->guiClient->domDocument().firstChild().firstChild().firstChild();
        while (!node.isNull())
        {
          if (node.nodeName() == "Action")
          {
            action = ac->action(node.toElement().attribute("name"));
            if (action)
            {
              oldItem = new KListViewItem(item, oldItem, action->text().replace(QRegExp("\\&(?!\\&)"),""), action->shortcut().toString(), action->name());
              oldItem->setPixmap(0, SmallIcon(action->icon()));
            }
          }
          node = node.nextSibling();
        }
      }
    }
    actionTreeView->setCurrentItem(allActionsItem);
    actionTreeView->setSelected(allActionsItem, true);
  }
}
Пример #13
0
void PageAutoConnect::readConfig()
{
    KConfig *conf = kapp->config();
    conf->setGroup("AutoConnect");
    QStringList servers = conf->readListEntry("Servers");
    servers.sort();
    QStringList::ConstIterator ser = servers.begin();
    for( ; ser != servers.end(); ser++){
        QStringList channels = conf->readListEntry(*ser);
	QString server = *ser;
	QString port = "6667";
	QString ssl = QString::null;
	QString pass = QString::null;

	QRegExp rx("(.+) \\(SSL\\)(.*)");
	if(rx.search(server) >= 0){
            server = rx.cap(1) + rx.cap(3);
            ssl = i18n("SSL");
	}
	rx.setPattern("(.+) \\(pass: (\\S+)\\)(.*)");
	if(rx.search(server) >= 0){
            server = rx.cap(1) + rx.cap(3);
            pass = rx.cap(2);
	}
	rx.setPattern("([^: ]+):(\\d+)");
	if(rx.search(server) >= 0){
            kdDebug(5008) << server << ": Has port:" << rx.cap(2)  << endl;
            server = rx.cap(1);
            port = rx.cap(2);
	}
	kdDebug(5008) << server << ": Done " << port << " " << ssl << " " << pass << endl;
        QListViewItem *s = new QListViewItem(KLVAutoConnect, server, port, pass, ssl);
        s->setOpen(TRUE);
        channels.sort();
        QStringList::ConstIterator chan = channels.begin();
	for(; chan != channels.end(); chan++){
            QString channel = *chan;
            QString key = QString::null;
            QRegExp crx("(.+) \\(key: (\\S+)\\)");
            if(crx.search(channel) >= 0){
		channel = crx.cap(1);
		key = crx.cap(2);
            }
            new QListViewItem(s, channel, key);
        }
    }
}
Пример #14
0
PlaylistSelection::PlaylistSelection( QWidget* parent, char* name )
    : KListView( parent, name )
{
    addColumn( i18n("Select Playlists") );
    setRootIsDecorated( true );
    PlaylistBrowserView* browserTree = PlaylistBrowser::instance()->getListView();
    QListViewItem*       browserItem = browserTree->firstChild();
    //load into the tree the first two items, which is the smart playlist and the playlist
    for( int i = 0; i<2; i++ )
    {
        QListViewItem* newItem = new QListViewItem( this, browserItem->text(0) );
        newItem->setPixmap( 0, *browserItem->pixmap(0) );
        loadChildren( browserItem, newItem );
        newItem->setOpen( true );
        browserItem = browserItem->nextSibling();
    }
}
Пример #15
0
void NewDevice::fillTree()
{
  QListViewItem* parent = NULL;
  QListViewItem* newItem = NULL;

  QPtrList <DeviceClass> *dl = _app->deviceClassList();

  QString path;
  _app->settings()->get("SystemPath", path);
  path += QString("/") + PIXMAPPATH;
  QPixmap pm(path + QString("/dmx.xpm"));

  QString tree;
  _app->settings()->get("NewDeviceTreeOpen", tree);
  bool treeOpen = (tree == Settings::trueValue()) ? true : false;

  m_tree->clear();

  for (DeviceClass* dc = dl->first(); dc != NULL; dc = dl->next())
    {
      bool alreadyAdded = false;

      for (QListViewItem* i = m_tree->firstChild(); 
	   i != NULL; i = i->nextSibling())
	{
	  if (i->text(0) == dc->manufacturer())
	    {
	      alreadyAdded = true;
	      parent = i;
	      break;
	    }
	}

      if (alreadyAdded == false)
	{
	  parent = new QListViewItem(m_tree, dc->manufacturer());
	  parent->setOpen(treeOpen);
	}

      parent->setPixmap(0, QPixmap(path + QString("/global.xpm")));

      newItem = new QListViewItem(parent, dc->model());
      newItem->setPixmap(0, pm);
      newItem->setText(1,dc->type());
    }
}
void AssetVersionProperties::refresh()
{
  depListView->clear();


  AssetVersion ver(verref);
  QListViewItem *item = new AssetChildItem( depListView, ver );

  // automatically open the first level
  item->setOpen( true );

  // auto size the window?
  for ( int col = 0; col < depListView->columns(); col++ ) {
    int w = depListView->columnWidth( col );
    depListView->setColumnWidth( col, w + 20 );
  }

}
Пример #17
0
QListViewItem *LibraryWindow::getTypeItem(const QString &type)
{
    QListViewItem *item = typeItemByType.find(type);
    if (item == 0) {
        item = new TypeListViewItem(this, modelListView_, type);
        item->setOpen(true);
        if (type == "I/O") {
            item->setPixmap(0, QPixmap(Util::findIcon("connect_established.png")));
        }
        else if (type == "CPU") {
            item->setPixmap(0, QPixmap(Util::findIcon("kcmprocessor.png")));
        }
        else if (type == "Core") {
            item->setPixmap(0, QPixmap(Util::findIcon("memory.png")));
        }
        typeItemByType.insert(type, item);
    }
    return item;
}
Пример #18
0
void
StdWidgetFactory::readListItem(QDomElement &node, QListViewItem *parent, KListView *listview)
{
	QListViewItem *item;
	if(parent)
		item = new KListViewItem(parent);
	else
		item = new KListViewItem(listview);

	// We need to move the item at the end of the list
	QListViewItem *last;
	if(parent)
		last = parent->firstChild();
	else
		last = listview->firstChild();

	while(last->nextSibling())
		last = last->nextSibling();
	item->moveItem(last);

	int i = 0;
	for(QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling())
	{
		QDomElement childEl = n.toElement();
		QString prop = childEl.attribute("name");
		QString tag = childEl.tagName();

		// We read sub items
		if(tag == "item")
		{
			item->setOpen(true);
			readListItem(childEl, item, listview);
		}
		// and column texts
		else if((tag == "property") && (prop == "text"))
		{
			QVariant val = KFormDesigner::FormIO::readPropertyValue(n.firstChild(), listview, "item");
			item->setText(i, val.toString());
			i++;
		}
	}
}
Пример #19
0
void NewDevice::fillTree()
{
  QListViewItem* parent = NULL;
  QListViewItem* newItem = NULL;

  QList <DeviceClass> dclist(_app->doc()->deviceClassList());
  QPixmap pm(_app->settings()->pixmapPath() + QString("dmx.xpm"));

  m_tree->clear();

  for (DeviceClass* dc = dclist.first(); dc != NULL; dc = dclist.next())
    {
      bool alreadyAdded = false;

      for (QListViewItem* i = m_tree->firstChild(); i != NULL; i = i->nextSibling())
	{
	  if (i->text(0) == dc->manufacturer())
	    {
	      alreadyAdded = true;
	      parent = i;
	      break;
	    }
	}

      if (alreadyAdded == false)
	{
	  parent = new QListViewItem(m_tree, dc->manufacturer());
	  if (_app->settings()->newDeviceTreeOpen() == true)
	    {
	      parent->setOpen(true);
	    }
	}

      parent->setPixmap(0, QPixmap(_app->settings()->pixmapPath() + QString("global.xpm")));

      newItem = new QListViewItem(parent, dc->model());
      newItem->setPixmap(0, pm);
      newItem->setText(1,dc->type());
    }
}
Пример #20
0
void servercontroller::new_ksircprocess(KSircServer &kss)
{
  QString server_id;
  int id = 1;
  if(kss.server().isEmpty())  // nothing entered, nothing done
    return;
  server_id = kss.server();
  while(proc_list[server_id]){   // if it already exists, quit
    server_id = QString("%1 %2").arg(kss.server()).arg(id++);
  }

  // Insert new base
  QListViewItem *rootItem = new QListViewItem( ConnectionTree, server_id );
  rootItem->setPixmap( 0, pic_server );
  rootItem->setOpen( true );

  // We do no_channel here since proc emits the signal in the
  // constructor, and we can't connect to before then, so we have to
  // do the dirty work here.
  ProcMessage(server_id, ProcCommand::addTopLevel, QString("no_channel"));

  KSircProcess *proc = new KSircProcess(server_id, kss, 0, (QString(name()) + "_" + server_id + "_ksp").ascii() ); // Create proc
  //this->insertChild(proc);                           // Add it to out inheritance tree so we can retreive child widgets from it.
  objFinder::insert(proc);
  proc_list.insert(server_id, proc);                      // Add proc to hash
  connect(proc, SIGNAL(ProcMessage(QString, int, QString)),
	  this, SLOT(ProcMessage(QString, int, QString)));
  connect(this, SIGNAL(ServMessage(QString, int, QString)),
	  proc, SLOT(ServMessage(QString, int, QString)));

  if(!ConnectionTree->currentItem()){   // If nothing's highlighted
    ConnectionTree->setCurrentItem(rootItem);     // highlight it.
  }

  connections->setItemEnabled(join_id, TRUE);

  dockWidget->serverOpen(server_id);
}
Пример #21
0
/**
 * Refresh the nicklistview for a single server.
 * @param server            The server to be refreshed.
 */
void NicksOnline::updateServerOnlineList(Server* servr)
{
    bool newNetworkRoot = false;
    QString serverName = servr->getServerName();
    QString networkName = servr->getDisplayName();
    QListViewItem* networkRoot = findNetworkRoot(networkName);
    // If network is not in our list, add it.
    if (!networkRoot)
    {
        networkRoot = new NicksOnlineItem(NicksOnlineItem::NetworkRootItem,m_nickListView,networkName);
        newNetworkRoot = true;
    }
    // Store server name in hidden column.
    // Note that there could be more than one server in the network connected,
    // but it doesn't matter because all the servers in a network have the same
    // watch list.
    networkRoot->setText(nlvcServerName, serverName);
    // Update list of servers in the network that are connected.
    QStringList serverList = QStringList::split(",", networkRoot->text(nlvcAdditionalInfo));
    if (!serverList.contains(serverName)) serverList.append(serverName);
    networkRoot->setText(nlvcAdditionalInfo, serverList.join(","));
    // Get item in nicklistview for the Offline branch.
    QListViewItem* offlineRoot = findItemType(networkRoot, NicksOnlineItem::OfflineItem);
    if (!offlineRoot)
    {
        offlineRoot = new NicksOnlineItem(NicksOnlineItem::OfflineItem,networkRoot,i18n("Offline"));
        offlineRoot->setText(nlvcServerName, serverName);
    }

    // Get watch list.
    QStringList watchList = servr->getWatchList();
    QStringList::iterator itEnd = watchList.end();
    QString nickname;

    for (QStringList::iterator it = watchList.begin(); it != itEnd; ++it)
    {
        nickname = (*it);
        NickInfoPtr nickInfo = getOnlineNickInfo(networkName, nickname);

        if (nickInfo && nickInfo->getPrintedOnline())
        {
            // Nick is online.
            // Which server did NickInfo come from?
            Server* server=nickInfo->getServer();
            // Get addressbook entry (if any) for the nick.
            KABC::Addressee addressee = nickInfo->getAddressee();
            // Construct additional information string for nick.
            bool needWhois = false;
            QString nickAdditionalInfo = getNickAdditionalInfo(nickInfo, addressee, needWhois);
            // Remove from offline branch if present.
            QListViewItem* item = findItemChild(offlineRoot, nickname, NicksOnlineItem::NicknameItem);
            if (item) delete item;
            // Add to network if not already added.
            QListViewItem* nickRoot = findItemChild(networkRoot, nickname, NicksOnlineItem::NicknameItem);
            if (!nickRoot) nickRoot = new NicksOnlineItem(NicksOnlineItem::NicknameItem,networkRoot, nickname, nickAdditionalInfo);
            nickRoot->setText(nlvcAdditionalInfo, nickAdditionalInfo);
            nickRoot->setText(nlvcServerName, serverName);
            // If no additional info available, request a WHOIS on the nick.
            if (!m_whoisRequested)
            {
                if (needWhois)
                {
                    requestWhois(networkName, nickname);
                    m_whoisRequested = true;
                }
            }
            // Set Kabc icon if the nick is associated with an addressbook entry.
            if (!addressee.isEmpty())
                nickRoot->setPixmap(nlvcKabc, m_kabcIconSet.pixmap(
                                        QIconSet::Small, QIconSet::Normal, QIconSet::On));
            else
                nickRoot->setPixmap(nlvcKabc, m_kabcIconSet.pixmap(
                                        QIconSet::Small, QIconSet::Disabled, QIconSet::Off));

            QStringList channelList = server->getNickChannels(nickname);
            QStringList::iterator itEnd2 = channelList.end();

            for (QStringList::iterator it2 = channelList.begin(); it2 != itEnd2; ++it2)
            {
                // Known channels where nickname is online and mode in each channel.
                // FIXME: If user connects to multiple servers in same network, the
                // channel info will differ between the servers, resulting in inaccurate
                // mode and led info displayed.

                QString channelName = (*it2);

                ChannelNickPtr channelNick = server->getChannelNick(channelName, nickname);
                QString nickMode;
                if (channelNick->hasVoice()) nickMode = nickMode + i18n(" Voice");
                if (channelNick->isHalfOp()) nickMode = nickMode + i18n(" HalfOp");
                if (channelNick->isOp()) nickMode = nickMode + i18n(" Operator");
                if (channelNick->isOwner()) nickMode = nickMode + i18n(" Owner");
                if (channelNick->isAdmin()) nickMode = nickMode + i18n(" Admin");
                QListViewItem* channelItem = findItemChild(nickRoot, channelName, NicksOnlineItem::ChannelItem);
                if (!channelItem) channelItem = new NicksOnlineItem(NicksOnlineItem::ChannelItem,nickRoot,
                            channelName, nickMode);
                channelItem->setText(nlvcAdditionalInfo, nickMode);

                // Icon for mode of nick in each channel.
                Images::NickPrivilege nickPrivilege = Images::Normal;
                if (channelNick->hasVoice()) nickPrivilege = Images::Voice;
                if (channelNick->isHalfOp()) nickPrivilege = Images::HalfOp;
                if (channelNick->isOp()) nickPrivilege = Images::Op;
                if (channelNick->isOwner()) nickPrivilege = Images::Owner;
                if (channelNick->isAdmin()) nickPrivilege = Images::Admin;
                if (server->getJoinedChannelMembers(channelName) != 0)
                    channelItem->setPixmap(nlvcChannel,
                                           KonversationApplication::instance()->images()->getNickIcon(nickPrivilege, false));
                else
                    channelItem->setPixmap(nlvcChannel,
                                           KonversationApplication::instance()->images()->getNickIcon(nickPrivilege, true));
            }
            // Remove channel if nick no longer in it.
            QListViewItem* child = nickRoot->firstChild();
            while (child)
            {
                QListViewItem* nextChild = child->nextSibling();
                if (channelList.find(child->text(nlvcNick)) == channelList.end())
                    delete child;
                child = nextChild;
            }
        }
        else
        {
            // Nick is offline.
            // Remove from online nicks, if present.
            QListViewItem* item = findItemChild(networkRoot, nickname, NicksOnlineItem::NicknameItem);
            if (item) delete item;
            // Add to offline list if not already listed.
            QListViewItem* nickRoot = findItemChild(offlineRoot, nickname, NicksOnlineItem::NicknameItem);
            if (!nickRoot) nickRoot = new NicksOnlineItem(NicksOnlineItem::NicknameItem,offlineRoot, nickname);
            nickRoot->setText(nlvcServerName, serverName);
            // Get addressbook entry for the nick.
            KABC::Addressee addressee = servr->getOfflineNickAddressee(nickname);
            // Format additional information for the nick.
            bool needWhois = false;
            QString nickAdditionalInfo = getNickAdditionalInfo(0, addressee, needWhois);
            nickRoot->setText(nlvcAdditionalInfo, nickAdditionalInfo);
            // Set Kabc icon if the nick is associated with an addressbook entry.
            if (!addressee.isEmpty())
                nickRoot->setPixmap(nlvcKabc, m_kabcIconSet.pixmap(
                                        QIconSet::Small, QIconSet::Normal, QIconSet::On));
            else
                nickRoot->setPixmap(nlvcKabc, m_kabcIconSet.pixmap(
                                        QIconSet::Small, QIconSet::Disabled, QIconSet::Off));
        }
    }
    // Erase nicks no longer being watched.
    QListViewItem* item = networkRoot->firstChild();
    while (item)
    {
        QListViewItem* nextItem = item->nextSibling();
        if (static_cast<NicksOnlineItem*>(item)->type() != NicksOnlineItem::OfflineItem)
        {
            QString nickname = item->text(nlvcNick);
            if ((watchList.find(nickname) == watchList.end()) &&
                    (serverName == item->text(nlvcServerName))) delete item;
        }
        item = nextItem;
    }
    item = offlineRoot->firstChild();

    if(item) {
        while (item)
        {
            QListViewItem* nextItem = item->nextSibling();
            QString nickname = item->text(nlvcNick);
            if ((watchList.find(nickname) == watchList.end()) &&
                    (serverName == item->text(nlvcServerName))) delete item;
            item = nextItem;
        }
    }
    else
    {
        delete offlineRoot;
    }
    // Expand server if newly added to list.
    if (newNetworkRoot)
    {
        networkRoot->setOpen(true);
        // Connect server NickInfo updates.
        connect (servr, SIGNAL(nickInfoChanged(Server*, const NickInfoPtr)),
                 this, SLOT(slotNickInfoChanged(Server*, const NickInfoPtr)));
    }
}
Пример #22
0
void PageAutoConnect::add_pressed()
{
    int fnd = 0;
    QListViewItem *s = 0;

    s = KLVAutoConnect->selectedItem();
    if(!s){ /* new item */
	QString server = ServerLE->text();
	QString ssl = QString::null;
	QString port;

	port.setNum(PortKI->value());
	if(sslCB->isChecked())
	    ssl = i18n("SSL");

	s = new QListViewItem(KLVAutoConnect, server, port, PassLE->text(), ssl);
	s->setOpen(TRUE);
	s = new QListViewItem(s, ChannelLE->text(), KeyLE->text());
        KLVAutoConnect->setCurrentItem(s);
    }
    else { /* update the existing one */
	QListViewItem *parent;
	QListViewItem *child;

	if(s->parent()){
	    parent = s->parent();
            child = s;
	}
	else {
	    parent = s;
            child = 0x0;
	}

	parent->setText(NAME, ServerLE->text());
	parent->setText(PK, QString("%1").arg(PortKI->value()));
	parent->setText(PASS, PassLE->text());
	if(sslCB->isChecked())
	    parent->setText(SSL, i18n("SSL"));
	else
	    parent->setText(SSL, QString::null);

	if(child){
	    child->setText(NAME, ChannelLE->text());
	    child->setText(PK, KeyLE->text());
	}
	else {
	    if(ChannelLE->text().length() > 0){
                fnd = 0;
		QListViewItem *c = parent->firstChild();
		for( ; c != 0 && fnd == 0; c = c->nextSibling()){
		    if(c->text(NAME) == ChannelLE->text()){
			c->setText(PK, KeyLE->text());
			fnd = 1;
		    }
		}
		if(fnd == 0){
		    new QListViewItem(parent, ChannelLE->text(), KeyLE->text());
		}
	    }
	}

    }
    changed();
}
Пример #23
0
/**
 * Clear and refill the ListView with those package items that
 * are defined by the list of all packages and the PackageSelector.
 */
void PackageListView::refreshView()
{
	abortLoadingPackageDetails();

	//if( m_parallelScanning == true )
	//{
		//TODO: bring back?
		// also start a thread for scanning the installed packages,
		// because they are more important and need hasUpdates first.
		//packageInstalledScanner->startScanningCategory(
		//	this, tree, categoryName, subcategoryName
		//);
	//}

	// reset everything
	m_categories.clear();
	this->clear(); emit cleared();
	m_loadedPackageCount = 0;
	m_installedPackageCount = 0;
	m_totalPackageCount = 0;

	// Get the list of shown packages
	m_packageSelector->setSourceList( m_allPackages );
	m_packageSelector->setDestinationList( m_shownPackages );
	if( m_packageSelector->perform() == IJob::Failure ) {
		kdDebug() << i18n( "PackageListView debug output",
			"PackageListView::refreshView(): "
			"Failed to select shown packages" )
			<< endl;
		return;
	}

	// scan the package descriptions (in an extra thread)
	m_multiplePackageLoader->setPackageList( m_shownPackages );
	m_multiplePackageLoader->start();


	// Insert packages under their right category in the ListView.
	// If the category doesn't exist yet, then a check ensures that
	// it is created before insertPackageItem() creates the package item.

	QListViewItem *catItem;
	QString categoryName, uniqueCategoryName;
	PackageList::iterator packageIteratorEnd = m_shownPackages->end();

	for( PackageList::iterator packageIterator = m_shownPackages->begin();
	     packageIterator != packageIteratorEnd; ++packageIterator )
	{
		//TODO: We want user visible names in categoryName.
		//      See emitSelectionChanged().
		categoryName = (*packageIterator)->category()->uniqueName();
		uniqueCategoryName = (*packageIterator)->category()->uniqueName();

		if( m_categories.contains(uniqueCategoryName) == false )
		{
			catItem = new KListViewItem( this, categoryName );
			catItem->setExpandable( true );
			catItem->setOpen( true );
			catItem->setPixmap( 0, pxCategoryItem );
			m_categories[uniqueCategoryName].item = catItem;
		}
		insertPackageItem(
			m_categories[uniqueCategoryName].item, *(*packageIterator)
		);
	}

	emit contentsChanged();

} // end of refreshView(...)
Пример #24
0
void UISearchPage::recvIO_SearchReply( IOMessage * io )
{
        if ( m_done == true )
                return ;


        // Order of appearance
        //
        // the first time a filename shows up it gets it's own line,
        // and if it shows up more than once it is reparented.

        QListViewItem * item = new QListViewItem( m_view );
        item->setText( UIPageView::Col_Name, io->find( "name" ) );
        item->setText( UIPageView::Col_Bitr, io->find( "bitrate" ) );
        item->setText( UIPageView::Col_Size, io->find( "size" ) );
        item->setText( UIPageView::Col_Time, io->find( "time" ) );
        item->setText( UIPageView::Col_Freq, io->find( "freq" ) );
        item->setText( UIPageView::Col_Link, io->find( "speed" ) );
        item->setText( UIPageView::Col_Nick, io->find( "nick" ) );
        item->setText( UIPageView::Col_Path, io->find( "path" ) );
        item->setText( UIPageView::Col_Host, io->find( "host" ) );

        //
        // count gets bumped, title gets updated
        //

        incrementCount();
        updateTitle();

        //
        // do some bizzare tree m_view stuff ?
        //

        QListViewItem * item2 = m_items->find( io->find( "name" ) );

        if ( item2 == 0 )
        {
                m_items->replace( io->find( "name" ), item );
        }
        else
        {
                QListViewItem * from = 0;

                if ( item2->text( UIPageView::Col_Path ).isEmpty() == false )
                {
                        from = new QListViewItem( m_view );
                        from->setText( UIPageView::Col_Name, io->find( "name" ) );
                        from->setOpen( true );
                        from->setPixmap( UIPageView::Col_Name, m_folder );

                        // also add this item under parent
                        m_view->takeItem( item2 );
                        from->insertItem( item2 );
                }
                else
                {
                        from = item2;
                }

                m_view->takeItem( item );
                from->insertItem( item );

                m_items->replace( io->find( "name" ), from );
        }

        m_view->triggerUpdate();
}
Пример #25
0
QuasarConfig::QuasarConfig(MainWindow* main)
    : QuasarWindow(main, "QuasarConfig"), _styleChanged(false)
{
    _helpSource = "quasar_config.html";

    QFrame* frame = new QFrame(this);

    _areas = new QListView(frame);
    _stack = new QWidgetStack(frame);

    _display = new QFrame(_stack);
    _i18n = new QFrame(_stack);

    _changeStyle = new QCheckBox(tr("Change Style?"), _display);
    _changeStyle->setMinimumSize(_changeStyle->sizeHint());
    connect(_changeStyle, SIGNAL(toggled(bool)), SLOT(slotChangeStyle(bool)));

    _style = new ComboBox(_display);
    _style->insertItem("");
    _style->insertStringList(QStyleFactory::keys());

    _changeColor = new QCheckBox(tr("Change Color?"), _display);
    _changeColor->setMinimumSize(_changeColor->sizeHint());
    connect(_changeColor, SIGNAL(toggled(bool)), SLOT(slotChangeColor(bool)));

    _color = new QPushButton(tr("New Color"), _display);
    connect(_color, SIGNAL(clicked()), SLOT(slotPickColor()));

    _changeFont = new QCheckBox(tr("Change Font?"), _display);
    _changeFont->setMinimumSize(_changeFont->sizeHint());
    connect(_changeFont, SIGNAL(toggled(bool)), SLOT(slotChangeFont(bool)));

    _font = new QPushButton(tr("Push To Choose"), _display);
    connect(_font, SIGNAL(clicked()), SLOT(slotPickFont()));

    QGridLayout* displayGrid = new QGridLayout(_display);
    displayGrid->setSpacing(3);
    displayGrid->setMargin(3);
    displayGrid->setRowStretch(3, 1);
    displayGrid->setColStretch(2, 1);
    displayGrid->addWidget(_changeStyle, 0, 0);
    displayGrid->addWidget(_style, 0, 1);
    displayGrid->addWidget(_changeColor, 1, 0);
    displayGrid->addWidget(_color, 1, 1);
    displayGrid->addWidget(_changeFont, 2, 0);
    displayGrid->addWidget(_font, 2, 1);

    QLabel* localeLabel = new QLabel(tr("Locale:"), _i18n);
    _locale = new ComboBox(_i18n);
    _locale->setMinimumWidth(_locale->fontMetrics().width("x") * 30);
    localeLabel->setBuddy(_locale);
    connect(_locale, SIGNAL(activated(int)), SLOT(slotLocaleChange()));

    QGroupBox* samples = new QGroupBox(tr("Data Formats"), _i18n);

    QLabel* positiveLabel = new QLabel(tr("Positive"), samples);
    QLabel* negativeLabel = new QLabel(tr("Negative"), samples);

    QLabel* numLabel = new QLabel(tr("Number:"), samples);
    _numberPosSample = new QLabel(samples);
    _numberNegSample = new QLabel(samples);

    QLabel* moneyLabel = new QLabel(tr("Currency:"), samples);
    _moneyPosSample = new QLabel(samples);
    _moneyNegSample = new QLabel(samples);

    QLabel* percentLabel = new QLabel(tr("Percent:"), samples);
    _percentPosSample = new QLabel(samples);
    _percentNegSample = new QLabel(samples);

    QLabel* dateLabel = new QLabel(tr("Date:"), samples);
    _dateSample = new QLabel(samples);

    QLabel* timeLabel = new QLabel(tr("Time:"), samples);
    _timeSample = new QLabel(samples);

    QGridLayout* sampleGrid = new QGridLayout(samples);
    sampleGrid->addRowSpacing(0, samples->fontMetrics().height());
    sampleGrid->setSpacing(3);
    sampleGrid->setMargin(10);
    sampleGrid->setColStretch(1, 1);
    sampleGrid->setColStretch(2, 1);
    sampleGrid->setRowStretch(3, 1);
    sampleGrid->addRowSpacing(3, 20);
    sampleGrid->addWidget(dateLabel, 1, 0);
    sampleGrid->addWidget(_dateSample, 1, 1, AlignRight|AlignVCenter);
    sampleGrid->addWidget(timeLabel, 2, 0);
    sampleGrid->addWidget(_timeSample, 2, 1, AlignRight|AlignVCenter);
    sampleGrid->addWidget(positiveLabel, 4, 1, AlignRight|AlignVCenter);
    sampleGrid->addWidget(negativeLabel, 4, 2, AlignRight|AlignVCenter);
    sampleGrid->addWidget(numLabel, 5, 0);
    sampleGrid->addWidget(_numberPosSample, 5, 1, AlignRight|AlignVCenter);
    sampleGrid->addWidget(_numberNegSample, 5, 2, AlignRight|AlignVCenter);
    sampleGrid->addWidget(moneyLabel, 6, 0);
    sampleGrid->addWidget(_moneyPosSample, 6, 1, AlignRight|AlignVCenter);
    sampleGrid->addWidget(_moneyNegSample, 6, 2, AlignRight|AlignVCenter);
    sampleGrid->addWidget(percentLabel, 7, 0);
    sampleGrid->addWidget(_percentPosSample, 7, 1, AlignRight|AlignVCenter);
    sampleGrid->addWidget(_percentNegSample, 7, 2, AlignRight|AlignVCenter);

    QGridLayout* i18nGrid = new QGridLayout(_i18n);
    i18nGrid->setSpacing(3);
    i18nGrid->setMargin(3);
    i18nGrid->addRowSpacing(1, 20);
    i18nGrid->setRowStretch(2, 1);
    i18nGrid->setColStretch(2, 1);
    i18nGrid->addWidget(localeLabel, 0, 0);
    i18nGrid->addWidget(_locale, 0, 1, AlignLeft | AlignVCenter);
    i18nGrid->addMultiCellWidget(samples, 2, 2, 0, 2);

    _stack->addWidget(_display, 0);
    _stack->addWidget(_i18n, 1);

    _areas->addColumn(tr("Area"), -1);
    _areas->setSorting(-1);
    _areas->header()->hide();
    connect(_areas, SIGNAL(selectionChanged()), SLOT(slotAreaChange()));

    QListViewItem* user = new QListViewItem(_areas, tr("User Configuration"));

    user->setOpen(true);
    new QListViewItem(user, tr("Internationalization"));
    QListViewItem* displayArea = new QListViewItem(user, tr("Display"));

    QFrame* buttons = new QFrame(frame);
    QPushButton* ok = new QPushButton(tr("&OK"), buttons);
    QPushButton* apply = new QPushButton(tr("&Apply"), buttons);
    QPushButton* defaults = new QPushButton(tr("&Defaults"), buttons);
    QPushButton* cancel = new QPushButton(tr("&Cancel"), buttons);

    ok->setMinimumSize(defaults->sizeHint());
    apply->setMinimumSize(defaults->sizeHint());
    defaults->setMinimumSize(defaults->sizeHint());
    cancel->setMinimumSize(defaults->sizeHint());

    connect(ok, SIGNAL(clicked()), SLOT(slotOk()));
    connect(apply, SIGNAL(clicked()), SLOT(slotApply()));
    connect(defaults, SIGNAL(clicked()), SLOT(slotDefaults()));
    connect(cancel, SIGNAL(clicked()), this, SLOT(slotCancel()));

    QGridLayout* buttonGrid = new QGridLayout(buttons);
    buttonGrid->setSpacing(3);
    buttonGrid->setMargin(3);
    buttonGrid->setColStretch(0, 1);
    buttonGrid->addWidget(ok, 0, 1);
    buttonGrid->addWidget(apply, 0, 2);
    buttonGrid->addWidget(defaults, 0, 3);
    buttonGrid->addWidget(cancel, 0, 4);

    QGridLayout* grid = new QGridLayout(frame);
    grid->setSpacing(3);
    grid->setMargin(3);
    grid->setColStretch(1, 1);
    grid->addWidget(_areas, 0, 0);
    grid->addWidget(_stack, 0, 1);
    grid->addMultiCellWidget(buttons, 1, 1, 0, 1);

    _config.load();
    _locales = Locale::getAvailableLocales(_localesCnt);

    slotDefaults();
    _areas->setCurrentItem(displayArea);
    _stack->raiseWidget(_display);
    _changeStyle->setFocus();

    setCentralWidget(frame);
    setCaption(tr("Quasar Configuration"));
    finalize();
}
Пример #26
0
    QListViewItem* ServerListDialog::insertServerGroup(ServerGroupSettingsPtr serverGroup)
    {
        // Produce a list of this server group's channels
        QString channels;

        Konversation::ChannelList channelList = serverGroup->channelList();
        Konversation::ChannelList::iterator channelIt;
        Konversation::ChannelList::iterator begin = channelList.begin();

        for(channelIt = begin; channelIt != channelList.end(); ++channelIt)
        {
            if (channelIt != begin)
                channels += ", ";

            channels += (*channelIt).name();
        }

        QListViewItem* networkItem = 0;

        // Insert the server group into the list
        networkItem = new ServerListItem(m_serverList,
                                  serverGroup->id(),
                                  serverGroup->sortIndex(),
                                  serverGroup->name(),
                                  serverGroup->identity()->getName(),
                                  channels);

        // Recreate expanded/collapsed state
        if (serverGroup->expanded())
            networkItem->setOpen(true);

        // Produce a list of this server group's servers and iterate over it
        Konversation::ServerList serverList = serverGroup->serverList();
        Konversation::ServerList::iterator serverIt;

        QListViewItem* serverItem = 0;
        int i = 0;

        for (serverIt = serverList.begin(); serverIt != serverList.end(); ++serverIt)
        {
            // Produce a string representation of the server object
            QString name = (*serverIt).host();

            if ((*serverIt).port() != 6667)
                name += ':' + QString::number((*serverIt).port());

            if ((*serverIt).SSLEnabled())
                name += + " (SSL)";

            // Insert the server into the list, as child of the server group list item
            serverItem = new ServerListItem(networkItem,
                                            serverGroup->id(),
                                            i,
                                            name,
                                            (*serverIt));

            // The listview shouldn't allow this to be dragged
            serverItem->setDragEnabled(false);

            // Initialize a pointer to the new location of the last edited server
            if (m_selectedItem && m_selectedServer==(*serverIt))
                m_selectedItemPtr = serverItem;

            ++i;
        }

        return networkItem;
    }
Пример #27
0
void UserConfig::fill()
{
    ConfigItem::curIndex = 1;
    lstBox->clear();
    QListViewItem *parentItem;
    if (m_contact){
        parentItem = new MainInfoItem(lstBox, CmdInfo);
        ClientDataIterator it(m_contact->clientData);
        void *data;
        while ((data = ++it) != NULL){
            Client *client = m_contact->clientData.activeClient(data, it.client());
            if (client == NULL)
                continue;
            CommandDef *cmds = client->infoWindows(m_contact, data);
            if (cmds){
                parentItem = NULL;
                for (; !cmds->text.isEmpty(); cmds++){
                    if (parentItem){
                        new ClientItem(parentItem, it.client(), data, cmds);
                    }else{
                        parentItem = new ClientItem(lstBox, it.client(), data, cmds);
                        parentItem->setOpen(true);
                    }
                }
            }
        }
    }

    parentItem = NULL;
    ClientUserData* data;
    if (m_contact) {
        data = &m_contact->clientData;
    } else {
        data = &m_group->clientData;
    }
    ClientDataIterator it(*data);
    list<unsigned> st;
    while (++it){
        if ((it.client()->protocol()->description()->flags & PROTOCOL_AR_USER) == 0)
            continue;
        if (parentItem == NULL){
            parentItem = new ConfigItem(lstBox, 0);
            parentItem->setText(0, i18n("Autoreply"));
            parentItem->setOpen(true);
        }
        for (const CommandDef *d = it.client()->protocol()->statusList(); !d->text.isEmpty(); d++){
            if ((d->id == STATUS_ONLINE) || (d->id == STATUS_OFFLINE))
                continue;
            list<unsigned>::iterator it;
            for (it = st.begin(); it != st.end(); ++it)
                if ((*it) == d->id)
                    break;
            if (it != st.end())
                continue;
            st.push_back(d->id);
            new ARItem(parentItem, d);
        }
    }

    parentItem = new ConfigItem(lstBox, 0);
    parentItem->setText(0, i18n("Settings"));
    parentItem->setPixmap(0, Pict("configure", lstBox->colorGroup().base()));
    parentItem->setOpen(true);
    CommandDef *cmd;
    CommandsMapIterator itc(CorePlugin::m_plugin->preferences);
    m_defaultPage = 0;
    while ((cmd = ++itc) != NULL){
        new PrefItem(parentItem, cmd);
        if (m_defaultPage == 0)
            m_defaultPage = cmd->id;
    }

    QFontMetrics fm(lstBox->font());
    unsigned w = 0;
    for (QListViewItem *item = lstBox->firstChild(); item; item = item->nextSibling()){
        w = QMAX(w, itemWidth(item, fm));
    }
    lstBox->setFixedWidth(w);
    lstBox->setColumnWidth(0, w - 2);
}
Пример #28
0
void *JabberBrowser::processEvent(Event *e)
{
    if (e->type() == EventAgentInfo){
        JabberAgentInfo *data = (JabberAgentInfo*)(e->param());
        if (m_search_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_search_id = "";
                    delete m_search;
                    m_search = NULL;
                    Command cmd;
                    cmd->id		= CmdBrowseSearch;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_search->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showSearch()));
                }
                m_search_id = "";
                return e->param();
            }
            m_search->m_search->addWidget(data);
            return e->param();
        }
        if (m_reg_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_reg_id = "";
                    delete m_reg;
                    m_reg = NULL;
                    Command cmd;
                    cmd->id		= CmdRegister;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_reg->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showReg()));
                }
                m_reg_id = "";
                return e->param();
            }
            m_reg->m_search->addWidget(data);
            return e->param();
        }
        if (m_config_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_config_id = "";
                    delete m_config;
                    m_config = NULL;
                    Command cmd;
                    cmd->id		= CmdBrowseConfigure;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_config->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showConfig()));
                }
                m_config_id = "";
                return e->param();
            }
            m_config->m_search->addWidget(data);
            return e->param();
        }
    }
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != this)
            return NULL;
        if (cmd->menu_id != MenuBrowser)
            return NULL;
        cmd->flags &= ~COMMAND_CHECKED;
        switch (cmd->id){
        case CmdOneLevel:
            if (!m_client->getAllLevels())
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdAllLevels:
            if (m_client->getAllLevels())
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdModeDisco:
            if (m_client->getBrowseType() & BROWSE_DISCO)
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdModeBrowse:
            if (m_client->getBrowseType() & BROWSE_BROWSE)
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdModeAgents:
            if (m_client->getBrowseType() & BROWSE_AGENTS)
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        }
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != this)
            return NULL;
        QListViewItem *item = m_list->currentItem();
        if (cmd->menu_id == MenuBrowser){
            cmd->flags &= ~COMMAND_CHECKED;
            unsigned mode = m_client->getBrowseType();
            switch (cmd->id){
            case CmdOneLevel:
                m_client->setAllLevels(false);
				changeMode();
                return e->param();
            case CmdAllLevels:
                m_client->setAllLevels(true);
				changeMode();
                return e->param();
            case CmdModeDisco:
				mode ^= BROWSE_DISCO;
                m_client->setBrowseType(mode);
				changeMode();
                return e->param();
            case CmdModeBrowse:
				mode ^= BROWSE_BROWSE;
                m_client->setBrowseType(mode);
				changeMode();
                return e->param();
            case CmdModeAgents:
				mode ^= BROWSE_AGENTS;
                m_client->setBrowseType(mode);
				changeMode();
                return e->param();
            }
            return NULL;
        }
        if (item){
            if (cmd->id == CmdBrowseSearch){
                if (m_search)
                    delete m_search;
                m_search = new JabberWizard(this, i18n("%1 Search") .arg(item->text(COL_NAME).utf8()), "find", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "search");
                m_search_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "search");
                return e->param();
            }
            if (cmd->id == CmdRegister){
                if (m_reg)
                    delete m_reg;
                m_reg = new JabberWizard(this, i18n("%1 Register") .arg(item->text(COL_NAME).utf8()), "reg", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "register");
                m_reg_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "register");
                return e->param();
            }
            if (cmd->id == CmdBrowseConfigure){
                if (m_config)
                    delete m_config;
                m_config = new JabberWizard(this, i18n("%1 Configure") .arg(item->text(COL_NAME).utf8()), "configure", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "data");
                m_config_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "data");
                return e->param();
            }
            if (cmd->id == CmdBrowseInfo){
                if (m_info == NULL)
                    m_info = new DiscoInfo(this, m_list->currentItem()->text(COL_FEATURES), item->text(COL_NAME), item->text(COL_TYPE), item->text(COL_CATEGORY));
                m_info->reset();
                raiseWindow(m_info);
                return e->param();
            }
        }
        if (cmd->id == CmdBack){
            if (m_historyPos){
                m_historyPos--;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == CmdForward){
            if (m_historyPos + 1 < (int)(m_history.size())){
                m_historyPos++;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == CmdUrl){
            if (m_bInProcess){
                stop("");
                return e->param();
            }
            QString jid;
            QString node;
            Command cmd;
            cmd->id		= CmdUrl;
            cmd->param	= this;
            Event eWidget(EventCommandWidget, cmd);
            CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process());
            if (cmbUrl)
                jid = cmbUrl->lineEdit()->text();
            cmd->id		= CmdNode;
            CToolCombo *cmbNode = (CToolCombo*)(eWidget.process());
            if (cmbNode)
                node = cmbNode->lineEdit()->text();
            if (!jid.isEmpty()){
                addHistory(jid);
                goUrl(jid, node);
            }
            return e->param();
        }
    }
    if (e->type() == EventDiscoItem){
        if (!m_bInProcess)
            return NULL;
        DiscoItem *item = (DiscoItem*)(e->param());
        QListViewItem *it = findItem(COL_ID_DISCO_ITEMS, item->id.c_str());
        if (it){
            if (item->jid.empty()){
                it->setText(COL_ID_DISCO_ITEMS, "");
                if (it != m_list->firstChild()){
                    checkDone();
                    adjustColumn(it);
                    return e->param();
                }
                QString err;
                if (!item->name.empty()){
                    err = QString::fromUtf8(item->name.c_str());
                }else if (!item->node.empty()){
                    err = i18n("Error %1") .arg(atol(item->node.c_str()));
                }
                if (!err.isEmpty()){
					unsigned mode = atol(it->text(COL_MODE).latin1());
					if (((mode & BROWSE_BROWSE) == 0) || (it->text(COL_ID_BROWSE).isEmpty() & m_bError))
                        stop(err);
                    m_bError = true;
                }
                checkDone();
                adjustColumn(it);
                return e->param();
            }
            if (it->firstChild() == NULL){
                it->setExpandable(true);
						if ((it == m_list->firstChild()) || (it == m_list->currentItem()))
							it->setOpen(true);
            }
            QListViewItem *i;
            for (i = it->firstChild(); i; i = i->nextSibling()){
                if ((i->text(COL_JID) == QString::fromUtf8(item->jid.c_str())) &&
                        (i->text(COL_NODE) == QString::fromUtf8(item->node.c_str())))
                    return e->param();
            }
            i = new QListViewItem(it);
            i->setText(COL_JID, QString::fromUtf8(item->jid.c_str()));
            i->setText(COL_NAME, item->name.empty() ? QString::fromUtf8(item->jid.c_str()) : QString::fromUtf8(item->name.c_str()));
            i->setText(COL_NODE, QString::fromUtf8(item->node.c_str()));
            int mode = 0;
            if (m_client->getBrowseType() & BROWSE_DISCO){
                i->setText(COL_ID_DISCO_INFO, m_client->discoInfo(item->jid.c_str(), item->node.c_str()).c_str());
                mode |= BROWSE_INFO;
            }
            i->setText(COL_MODE, QString::number(mode));
			if (m_client->getAllLevels())
				loadItem(i);
            return e->param();
        }
        it = findItem(COL_ID_DISCO_INFO, item->id.c_str());
        if (it){
            if (item->jid.empty()){
                it->setText(COL_ID_DISCO_INFO, "");
                checkDone();
                adjustColumn(it);
                return e->param();
            }
            if (it->text(COL_NAME) == it->text(COL_JID))
                it->setText(COL_NAME, QString::fromUtf8(item->name.c_str()));
            it->setText(COL_CATEGORY, QString::fromUtf8(item->category.c_str()));
            it->setText(COL_TYPE, QString::fromUtf8(item->type.c_str()));
            it->setText(COL_FEATURES, QString::fromUtf8(item->features.c_str()));
            if ((m_client->getAllLevels()) || (it == m_list->currentItem()))
				loadItem(it);
            setItemPict(it);
            if (it == m_list->currentItem())
                currentChanged(it);
            return e->param();
        }
        it = findItem(COL_ID_BROWSE, item->id.c_str());
        if (it){
            if (item->jid.empty()){
                it->setText(COL_ID_BROWSE, "");
                if (it != m_list->firstChild()){
                    checkDone();
                    adjustColumn(it);
                    return e->param();
                }
                    QString err;
                    if (!item->name.empty()){
                        err = QString::fromUtf8(item->name.c_str());
                    }else if (!item->node.empty()){
                        err = i18n("Error %1") .arg(atol(item->node.c_str()));
                    }
                if (!err.isEmpty()){
					unsigned mode = atol(it->text(COL_MODE).latin1());
					if (((mode & BROWSE_DISCO) == 0) || (it->text(COL_ID_DISCO_ITEMS).isEmpty() & m_bError))
                        stop(err);
                    m_bError = true;
                }
                checkDone();
				adjustColumn(it);
                return e->param();
            }
            if (it->text(COL_JID) != QString::fromUtf8(item->jid.c_str())){
                QListViewItem *i;
                for (i = it->firstChild(); i; i = i->nextSibling()){
                    if ((i->text(COL_JID) == QString::fromUtf8(item->jid.c_str())) &&
                            (i->text(COL_NODE) == QString::fromUtf8(item->node.c_str())))
                        break;
                }
                if (i){
                    it = i;
                }else{
					if (it->firstChild() == NULL){
						it->setExpandable(true);
						if ((it == m_list->firstChild()) || (it == m_list->currentItem()))
							it->setOpen(true);
					}
                    it = new QListViewItem(it);
                    it->setText(COL_JID, QString::fromUtf8(item->jid.c_str()));
                    if (m_client->getAllLevels())
						loadItem(it);
                }
            }
            if (it->text(COL_NAME) == it->text(COL_JID))
                it->setText(COL_NAME, QString::fromUtf8(item->name.c_str()));
            it->setText(COL_CATEGORY, QString::fromUtf8(item->category.c_str()));
            it->setText(COL_TYPE, QString::fromUtf8(item->type.c_str()));
            it->setText(COL_FEATURES, QString::fromUtf8(item->features.c_str()));
            if (m_client->getAllLevels() || (it == m_list->currentItem()))
				loadItem(it);
            setItemPict(it);
            return e->param();
        }
    }
    return NULL;
}
Пример #29
0
void ProcAttachPS::pushLine()
{
    if (m_line.size() < 3)	// we need the PID, PPID, and COMMAND columns
	return;

    if (m_pidCol < 0)
    {
	// create columns if we don't have them yet
	bool allocate =	processList->columns() == 3;

	// we assume that the last column is the command
	m_line.pop_back();

	for (uint i = 0; i < m_line.size(); i++) {
	    // we don't allocate the PID and PPID columns,
	    // but we need to know where in the ps output they are
	    if (m_line[i] == "PID") {
		m_pidCol = i;
	    } else if (m_line[i] == "PPID") {
		m_ppidCol = i;
	    } else if (allocate) {
		processList->addColumn(m_line[i]);
		// these columns are normally numbers
		processList->setColumnAlignment(processList->columns()-1,
						Qt::AlignRight);
	    }
	}
    }
    else
    {
	// insert a line
	// find the parent process
	QListViewItem* parent = 0;
	if (m_ppidCol >= 0 && m_ppidCol < int(m_line.size())) {
	    parent = processList->findItem(m_line[m_ppidCol], 1);
	}

	// we assume that the last column is the command
	QListViewItem* item;
	if (parent == 0) {
	    item = new QListViewItem(processList, m_line.back());
	} else {
	    item = new QListViewItem(parent, m_line.back());
	}
	item->setOpen(true);
	m_line.pop_back();
	int k = 3;
	for (uint i = 0; i < m_line.size(); i++)
	{
	    // display the pid and ppid columns' contents in columns 1 and 2
	    if (int(i) == m_pidCol)
		item->setText(1, m_line[i]);
	    else if (int(i) == m_ppidCol)
		item->setText(2, m_line[i]);
	    else
		item->setText(k++, m_line[i]);
	}

	if (m_ppidCol >= 0 && m_pidCol >= 0) {	// need PID & PPID for this
	    /*
	     * It could have happened that a process was earlier inserted,
	     * whose parent process is the current process. Such processes
	     * were placed at the root. Here we go through all root items
	     * and check whether we must reparent them.
	     */
	    QListViewItem* i = processList->firstChild();
	    while (i != 0)
	    {
		// advance before we reparent the item
		QListViewItem* it = i;
		i = i->nextSibling();
		if (it->text(2) == m_line[m_pidCol]) {
		    processList->takeItem(it);
		    item->insertItem(it);
		}
	    }
	}
    }
}
Пример #30
0
void HierarchyList::insertObject( QObject *o, QListViewItem *parent )
{
    bool fakeMainWindow = false;
    if ( o && o->inherits( "QMainWindow" ) ) {
  QObject *cw = ( (QMainWindow*)o )->centralWidget();
  if ( cw ) {
      o = cw;
      fakeMainWindow = true;
  }
    }
    QListViewItem *item = 0;
    QString className = WidgetFactory::classNameOf( o );
    if ( o->inherits( "QLayoutWidget" ) ) {
  switch ( WidgetFactory::layoutType( (QWidget*)o ) ) {
  case WidgetFactory::HBox:
      className = "HBox";
      break;
  case WidgetFactory::VBox:
      className = "VBox";
      break;
  case WidgetFactory::Grid:
      className = "Grid";
      break;
  default:
      break;
  }
    }

    QString dbInfo;
#ifndef QT_NO_SQL
    dbInfo = MetaDataBase::fakeProperty( o, "database" ).toStringList().join(".");
#endif

    QString name = o->name();
    if ( o->parent() && o->parent()->inherits( "QWidgetStack" ) &&
   o->parent()->parent() ) {
  if ( o->parent()->parent()->inherits( "QTabWidget" ) )
      name = ( (QTabWidget*)o->parent()->parent() )->tabLabel( (QWidget*)o );
  else if ( o->parent()->parent()->inherits( "QWizard" ) )
      name = ( (QWizard*)o->parent()->parent() )->title( (QWidget*)o );
    }

    QToolBox *tb;
    if ( o->parent() && o->parent()->parent() &&
     (tb = ::qt_cast<QToolBox*>(o->parent()->parent()->parent())) )
    name = tb->itemLabel( tb->indexOf((QWidget*)o) );


    if ( fakeMainWindow ) {
  name = o->parent()->name();
  className = "QMainWindow";
    }

    if ( !parent )
  item = new HierarchyItem( HierarchyItem::Widget, this, name, className, dbInfo );
    else
  item = new HierarchyItem( HierarchyItem::Widget, parent, name, className, dbInfo );
    if ( !parent )
  item->setPixmap( 0, PixmapChooser::loadPixmap( "form.xpm", PixmapChooser::Mini ) );
    else if ( o->inherits( "QLayoutWidget") )
  item->setPixmap( 0, PixmapChooser::loadPixmap( "layout.xpm", PixmapChooser::Small ) );
    else
  item->setPixmap( 0, WidgetDatabase::iconSet( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( o ) ) ).
       pixmap( QIconSet::Small, QIconSet::Normal ) );
    ( (HierarchyItem*)item )->setWidget( (QWidget*)o );

    const QObjectList *l = o->children();
    if ( !l )
  return;
    QObjectListIt it( *l );
    it.toLast();
    for ( ; it.current(); --it ) {
  if ( !it.current()->isWidgetType() || ( (QWidget*)it.current() )->isHidden() )
      continue;
  if (  !formWindow->widgets()->find( (QWidget*)it.current() ) ) {
      if ( it.current()->parent() &&
     ( it.current()->parent()->inherits( "QTabWidget" ) ||
       it.current()->parent()->inherits( "QWizard" ) ) &&
     it.current()->inherits( "QWidgetStack" ) ) {
    QObject *obj = it.current();
    QObjectList *l2 = obj->queryList( "QWidget", 0, true, false );
    QDesignerTabWidget *tw = 0;
    QDesignerWizard *dw = 0;
    if ( it.current()->parent()->inherits( "QTabWidget" ) )
        tw = (QDesignerTabWidget*)it.current()->parent();
    if ( it.current()->parent()->inherits( "QWizard" ) )
      dw = (QDesignerWizard*)it.current()->parent();
    QWidgetStack *stack = (QWidgetStack*)obj;
    for ( obj = l2->last(); obj; obj = l2->prev() ) {
        if ( qstrcmp( obj->className(), "QWidgetStackPrivate::Invisible" ) == 0 ||
       ( tw && !tw->tabBar()->tab( stack->id( (QWidget*)obj ) ) ) ||
       ( dw && dw->isPageRemoved( (QWidget*)obj ) ) )
      continue;
        insertObject( obj, item );
    }
    delete l2;
      } else if ( ::qt_cast<QToolBox*>(it.current()->parent()) ) {
            if ( !::qt_cast<QScrollView*>(it.current()) )
            continue;
            QToolBox *tb = (QToolBox*)it.current()->parent();
            for ( int i = tb->count() - 1; i >= 0; --i )
            insertObject( tb->item( i ), item );
        }
      continue;
  }
  insertObject( it.current(), item );
    }

    if ( item->firstChild() )
  item->setOpen( true );
}