예제 #1
0
TQString CharactersWidget::text() const
{
    TQString res = TQString::fromLatin1("");

    if (_regexp->wordChar())
        res += i18n("- A word character\n");

    if (_regexp->nonWordChar())
        res += i18n("- A non-word character\n");

    if (_regexp->digit())
        res += i18n("- A digit character\n");

    if (_regexp->nonDigit())
        res += i18n("- A non-digit character\n");

    if ( _regexp->space() )
        res += i18n("- A space character\n");

    if ( _regexp->nonSpace() )
        res += i18n("- A non-space character\n");

    // Single characters
    TQStringList chars = _regexp->chars();
    if ( !chars.isEmpty() ) {
        TQString str = chars.join( TQString::fromLocal8Bit(", ") );
        res += TQString::fromLocal8Bit("- ") + str + TQString::fromLocal8Bit("\n");
    }

    // Ranges characters
    TQPtrList<StringPair> range = _regexp->range();
    for ( TQPtrListIterator<StringPair> it( range ); *it; ++it ) {
        StringPair* elm = static_cast<StringPair*>(*it);
        if (elm) {
            TQString fromText = elm->first();
            TQString toText = elm->second();

            res += TQString::fromLocal8Bit("- ") + i18n("from ") + fromText + i18n(" to ") + toText + TQString::fromLocal8Bit("\n");
        }
    }
    return res.left(res.length()-1);
}
예제 #2
0
void KFSConfigPage::init()
{
  TDEConfig *config = kapp->config();
  config->setGroup( "fileselector" );
  // toolbar
  TQStringList l = config->readListEntry( "toolbar actions", ',' );
  if ( l.isEmpty() ) // default toolbar
    l << "up" << "back" << "forward" << "home" <<
                "short view" << "detailed view" <<
                "bookmarks" << "sync_dir";

  // actions from diroperator + two of our own
  TQStringList allActions;
  allActions << "up" << "back" << "forward" << "home" <<
                "reload" << "mkdir" << "delete" <<
                "short view" << "detailed view" /*<< "view menu" <<
                "show hidden" << "properties"*/ <<
                "bookmarks" << "sync_dir";
  TQRegExp re("&(?=[^&])");
  TDEAction *ac;
  TQListBox *lb;
  for ( TQStringList::Iterator it=allActions.begin(); it != allActions.end(); ++it ) {
    lb = l.contains( *it ) ? acSel->selectedListBox() : acSel->availableListBox();
    if ( *it == "bookmarks" || *it == "sync_dir" )
      ac = fileSelector->actionCollection()->action( (*it).latin1() );
    else
      ac = fileSelector->dirOperator()->actionCollection()->action( (*it).latin1() );
    if ( ac )
      new ActionLBItem( lb, SmallIcon( ac->icon() ), ac->text().replace( re, "" ), *it );
  }

  // sync
  int s = fileSelector->autoSyncEvents;
  cbSyncActive->setChecked( s & KateFileSelector::DocumentChanged );
  cbSyncShow->setChecked( s & KateFileSelector::GotVisible );
  // histories
  sbPathHistLength->setValue( fileSelector->cmbPath->maxItems() );
  sbFilterHistLength->setValue( fileSelector->filter->maxCount() );
  // session
  cbSesLocation->setChecked( config->readBoolEntry( "restore location", true ) );
  cbSesFilter->setChecked( config->readBoolEntry( "restore last filter", true ) );
}
예제 #3
0
void KateFileSelector::setupToolbar( TDEConfig *config )
{
  toolbar->clear();
  TQStringList tbactions = config->readListEntry( "toolbar actions", ',' );
  if ( tbactions.isEmpty() ) {
    // reasonable collection for default toolbar
    tbactions << "up" << "back" << "forward" << "home" <<
                "short view" << "detailed view" <<
                "bookmarks" << "sync_dir";
  }
  TDEAction *ac;
  for ( TQStringList::Iterator it=tbactions.begin(); it != tbactions.end(); ++it ) {
    if ( *it == "bookmarks" || *it == "sync_dir" )
      ac = mActionCollection->action( (*it).latin1() );
    else
      ac = dir->actionCollection()->action( (*it).latin1() );
    if ( ac )
      ac->plug( toolbar );
  }
}
예제 #4
0
MenuInfo::MenuInfo(const TQString& desktopFile)
{
    KSimpleConfig df(locate("data", TQString::fromLatin1("kicker/menuext/%1").arg(desktopFile)));
    df.setGroup("Desktop Entry");

    TQStringList list = df.readListEntry("X-TDE-AuthorizeAction");
    if (kapp && !list.isEmpty())
    {
       for(TQStringList::ConstIterator it = list.begin();
           it != list.end();
           ++it)
       {
          if (!kapp->authorize((*it).stripWhiteSpace()))
             return;
       }
    }

    name_ = df.readEntry("Name");
    comment_ = df.readEntry("Comment");
    icon_ = df.readEntry("Icon");
    library_ = df.readEntry("X-TDE-Library");
    desktopfile_ = desktopFile;
}
예제 #5
0
bool KURIFilter::filterURI( KURIFilterData& data, const TQStringList& filters )
{
    bool filtered = false;
    KURIFilterPluginList use_plugins;

    // If we have a filter list, only include the once
    // explicitly specified by it. Otherwise, use all available filters...
    if( filters.isEmpty() )
        use_plugins = m_lstPlugins;  // Use everything that is loaded...
    else
    {
        //kdDebug() << "Named plugins requested..."  << endl;
        for( TQStringList::ConstIterator lst = filters.begin(); lst != filters.end(); ++lst )
        {
            TQPtrListIterator<KURIFilterPlugin> it( m_lstPlugins );
            for( ; it.current() ; ++it )
            {
                if( (*lst) == it.current()->name() )
                {
                    //kdDebug() << "Will use filter plugin named: " << it.current()->name() << endl;
                    use_plugins.append( it.current() );
                    break;  // We already found it ; so lets test the next named filter...
                }
            }
        }
    }

    TQPtrListIterator<KURIFilterPlugin> it( use_plugins );
    //kdDebug() << "Using " << use_plugins.count() << " out of the "
    //          << m_lstPlugins.count() << " available plugins" << endl;
    for (; it.current() && !filtered; ++it)
    {
        //kdDebug() << "Using a filter plugin named: " << it.current()->name() << endl;
        filtered |= it.current()->filterURI( data );
    }
    return filtered;
}
예제 #6
0
void KJanusWidget::addPageWidget( TQFrame *page, const TQStringList &items,
				  const TQString &header,const TQPixmap &pixmap )
{
  connect(page, TQT_SIGNAL(destroyed(TQObject*)), TQT_SLOT(pageGone(TQObject*)));

  if( mFace == Tabbed )
  {
    mTabControl->addTab (page, items.last());
    d->mIntToPage[d->mNextPageIndex] = static_cast<TQWidget*>(page);
    d->mPageToInt[static_cast<TQWidget*>(page)] = d->mNextPageIndex;
    d->mNextPageIndex++;
  }
  else if( mFace == TreeList || mFace == IconList )
  {
    d->mIntToPage[d->mNextPageIndex] = static_cast<TQWidget*>(page);
    d->mPageToInt[static_cast<TQWidget*>(page)] = d->mNextPageIndex;
    mPageStack->addWidget( page, 0 );

    if (items.isEmpty()) {
      kdDebug() << "Invalid TQStringList, with zero items" << endl;
      return;
    }

    if( mFace == TreeList )
    {
      InsertTreeListItem(items, pixmap, page);
    }
    else // mFace == IconList
    {
      TQString itemName = items.last();
      IconListItem *item = new IconListItem( mIconList, pixmap, itemName );
      mIconListToPageStack.insert(item, page);
      mIconList->invalidateHeight();
      mIconList->invalidateWidth();

      if (mIconList->isVisible())
        mIconList->updateWidth();
    }

    //
    // Make sure the title label is sufficiently wide
    //
    TQString lastName = items.last();
    const TQString &title = (!header.isNull() ? header : lastName);
    TQRect r = mTitleLabel->fontMetrics().boundingRect( title );
    if( mTitleLabel->minimumWidth() < r.width() )
    {
      mTitleLabel->setMinimumWidth( r.width() );
    }
    d->mIntToTitle[d->mNextPageIndex] = title;
    if( d->mIntToTitle.count() == 1 )
    {
      showPage(0);
    }
    d->mNextPageIndex++;
  }
  else
  {
    kdDebug() << "KJanusWidget::addPageWidget: can only add a page in Tabbed, TreeList or IconList modes" << endl;
  }

}
예제 #7
0
/*
   we just simplify the process. if we use KParts::BrowserExtension, we have to do
   lots extra work, adding so much classes. so just hack like following.

   grab useful code from TDEHTMLPopupGUIClient(tdehtml_ext.cpp),
   and change a little bit to fit our needs

*/
void EvaChatView::slotPopupMenu( const TQString & _url, const TQPoint & point )
{
    menu->clear();

    bool isImage = false;
    bool hasSelection = TDEHTMLPart::hasSelection();
    KURL url = KURL(_url);

    if(d) delete d;
    d = new MenuPrivateData;
    d->m_url = url;


    DOM::Element e = nodeUnderMouse();
    if ( !e.isNull() && (e.elementId() == ID_IMG) ) {
        DOM::HTMLImageElement ie = static_cast<DOM::HTMLImageElement>(e);
        TQString src = ie.src().string();
        d->m_imageURL = KURL(src);
        d->m_suggestedFilename = src.right(src.length() - src.findRev("/") -1);
        isImage=true;
    }


    TDEAction *action = 0L;

    if(hasSelection) {
        //action =  new TDEAction( i18n( "&Copy Text" ), TDEShortcut("Ctrl+C"), this, SLOT( copy() ),
        //			actionCollection(), "copy" );
        //action = KStdAction::copy( browserExtension(), SLOT(copy()), actionCollection(), "copy");
        //action->setText(i18n("&Copy Text"));
        //action->setEnabled(true);
        copyAction->plug(menu);

        // search text
        TQString selectedText = TDEHTMLPart::selectedText();
        if ( selectedText.length()>18 ) {
            selectedText.truncate(15);
            selectedText+="...";
        }
#ifdef HAS_KONTQUEROR
        // Fill search provider entries
        TDEConfig config("kuriikwsfilterrc");
        config.setGroup("General");
        const TQString defaultEngine = config.readEntry("DefaultSearchEngine", "google");
        const char keywordDelimiter = config.readNumEntry("KeywordDelimiter", ':');


        // default search provider
        KService::Ptr service = KService::serviceByDesktopPath(TQString("searchproviders/%1.desktop").arg(defaultEngine));

        // search provider icon
        TQPixmap icon;
        KURIFilterData data;
        TQStringList list;
        const TQString defaultSearchProviderPrefix = *(service->property("Keys").toStringList().begin()) + keywordDelimiter;
        data.setData( defaultSearchProviderPrefix + TQString("some keyword") );
        list << "kurisearchfilter" << "kuriikwsfilter";

        TQString name;
        if ( KURIFilter::self()->filterURI(data, list) ) {
            TQString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png");
            if ( iconPath.isEmpty() )
                icon = SmallIcon("edit-find");
            else
                icon = TQPixmap( iconPath );

            name = service->name();
        } else {
            icon = SmallIcon("google");
            name = "Google";
        }

        action = new TDEAction( i18n( "Search '%1' at %2" ).arg( selectedText ).arg( name ), icon, 0, this,
                                SLOT( searchProvider() ), actionCollection(), "searchProvider" );
        action->plug(menu);

        // favorite search providers
        TQStringList favoriteEngines;
        favoriteEngines = config.readListEntry("FavoriteSearchEngines"); // for KDE 3.2 API compatibility
        if(favoriteEngines.isEmpty())
            favoriteEngines << "google" << "google_groups" << "google_news" << "webster" << "dmoz" << "wikipedia";

        if ( !favoriteEngines.isEmpty()) {
            TDEActionMenu* providerList = new TDEActionMenu( i18n( "Search '%1' At" ).arg( selectedText ), actionCollection(), "searchProviderList" );
            bool hasSubMenus = false;
            TQStringList::ConstIterator it = favoriteEngines.begin();
            for ( ; it != favoriteEngines.end(); ++it ) {
                if (*it==defaultEngine)
                    continue;
                service = KService::serviceByDesktopPath(TQString("searchproviders/%1.desktop").arg(*it));
                if (!service)
                    continue;
                const TQString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + keywordDelimiter;
                data.setData( searchProviderPrefix + "some keyword" );

                if ( KURIFilter::self()->filterURI(data, list) ) {
                    TQString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png");
                    if ( iconPath.isEmpty() )
                        icon = SmallIcon("edit-find");
                    else
                        icon = TQPixmap( iconPath );
                    name = service->name();

                    providerList->insert( new TDEAction( name, icon, 0, this,
                                                         SLOT( searchProvider() ), actionCollection(), TQString( "searchProvider" + searchProviderPrefix ).latin1() ) );
                    hasSubMenus = true;
                }
            }
            if(hasSubMenus) providerList->plug(menu);
        }
#endif // HAS_KONTQUEROR
        if ( selectedText.contains("://") && KURL(selectedText).isValid() ) {
            action = new TDEAction( i18n( "Open '%1'" ).arg( selectedText ), "window_new", 0,
                                    this, SLOT( openSelection() ), actionCollection(), "openSelection" );
            action->plug(menu);
        }
    }
    if ( !url.isEmpty() ) {
        if (url.protocol() == "mailto")	{
            action = new TDEAction( i18n( "Copy Email Address" ), 0, this, SLOT( slotCopyLinkLocation() ),
                                    actionCollection(), "copylinklocation" );
            action->plug(menu);
        } else {
            action = new TDEAction( i18n( "Copy &Link Address" ), 0, this, SLOT( slotCopyLinkLocation() ),
                                    actionCollection(), "copylinklocation" );
            action->plug(menu);
        }
    }

    if (isImage)	{
#ifndef QT_NO_MIMECLIPBOARD
        action = (new TDEAction( i18n( "Copy Image" ), 0, this, SLOT( slotCopyImage() ),
                                 actionCollection(), "copyimage" ));
        action->plug(menu);
#endif
        action = new TDEAction( i18n( "Save Image As..." ), 0, this, SLOT( slotSaveImageAs() ),
                                actionCollection(), "saveimageas" );
        action->plug(menu);

        action = new TDEAction( i18n( "Save As Custom Smiley"), 0, this, SLOT( slotSaveAsCustomSmiley() ),
                                actionCollection(), "saveascustomsmiley" );
        action->plug(menu);
    }

    if(menu->count()) menu->popup(point);
}
예제 #8
0
void CpuView::updateCpu(CpuData &cpu, int cpuNumber)
{
#ifdef Q_OS_LINUX
  if (!m_procStream)
    return;

  bool cpuFound = false;
  TQString output;
  TQString parser;
  TQString cpuString;
  cpuString.setNum(cpuNumber).prepend("cpu");

  // Parse the proc file
  while (!m_procStream->atEnd()) {
    parser = m_procStream->readLine();
    // remove all the entries apart from the line containing 'cpuString'
    if (!cpuFound && parser.find(TQRegExp(cpuString)) != -1) {
      output = parser;
      cpuFound = true;
    }
  }

  TQStringList cpuList = TQStringList::split(' ', output);

  if (!cpuList.isEmpty()) {
    cpu.name = cpuList[0].stripWhiteSpace();
    cpu.user = cpuList[1].toULong();
    cpu.nice = cpuList[2].toULong();
    cpu.sys = cpuList[3].toULong();
    cpu.idle = cpuList[4].toULong();
  }

  fseek(m_procFile, 0L, SEEK_SET);
#endif

#ifdef __DragonFly__
  struct kinfo_cputime cp_time;
  if (kinfo_get_sched_cputime(&cp_time))
    err(1, "kinfo_get_sched_cputime");
  cpu.user = cp_time.cp_user;
  cpu.nice = cp_time.cp_nice;
  cpu.sys = cp_time.cp_sys;
  cpu.idle = cp_time.cp_idle;
#elif defined(Q_OS_FREEBSD)
#warning "add support for SMP on FreeBSD"
  Q_UNUSED(cpuNumber);
  static int name2oid[2] = { 0, 3 };
  static int oidCpuTime[CTL_MAXNAME + 2];
  static size_t oidCpuTimeLen = sizeof(oidCpuTime);
  long cpuTime[CPUSTATES];
  size_t cpuTimeLen = sizeof(cpuTime);
  static char name[] = "kern.cp_time";
  static int initialized = 0;

  if (!initialized) {
    if (sysctl(name2oid, 2, oidCpuTime, &oidCpuTimeLen,
       name, strlen(name)) < 0)
      return;

    oidCpuTimeLen /= sizeof(int);
    initialized = 1;
  }

  if (sysctl(oidCpuTime, oidCpuTimeLen,
     cpuTime, &cpuTimeLen, 0, 0) < 0)
    return;

  cpu.user = cpuTime[CP_USER];
  cpu.nice = cpuTime[CP_NICE];
  cpu.sys = cpuTime[CP_SYS];
  cpu.idle = cpuTime[CP_IDLE];
#endif

#if defined(Q_OS_NETBSD)
#define KERN_CPTIME KERN_CP_TIME
#endif
#if defined(Q_OS_OPENBSD) || defined(Q_OS_NETBSD)
//#warning "add support for SMP on OpenBSD and NetBSD"
  int name2oid[2] = { CTL_KERN, KERN_CPTIME };
  long cpuTime[CPUSTATES];
  size_t cpuTimeLen = sizeof(cpuTime);

  if (sysctl(name2oid, 2, &cpuTime, &cpuTimeLen,
     0, 0) < 0)
    return;

  cpu.user = cpuTime[CP_USER];
  cpu.nice = cpuTime[CP_NICE];
  cpu.sys = cpuTime[CP_SYS];
  cpu.idle = cpuTime[CP_IDLE];
#endif
}