Ejemplo n.º 1
0
void QLineEditEx::keyPressEvent(QKeyEvent *e)
{
    if(e->key() == Qt::Key_Up)	
	{
		loadHistory(true,m_History,m_Index);
		return;
	}
    else if (e->key() == Qt::Key_Down)
	{
		loadHistory(false,m_History,m_Index);
		return;
	}
	else if(e->key() == Qt::Key_Left)
	{
		if(m_TabIndex != -1)
		{
			suggest(false);
			return;
		}
	}
	else if(e->key() == Qt::Key_Right)
	{
		if(cursorPosition() == text().length() || m_TabIndex != -1)
		{
			suggest(true);
			return;
		}
	}
	else
	{
		m_TabBase.clear();
		m_TabIndex = -1;
	}
	QLineEdit::keyPressEvent(e);
}
Ejemplo n.º 2
0
BOOL CConnectRemoteMachineWindow::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	m_port.SetWindowTextW(L"20099");

	loadHistory();

	int i = 0;
	std::deque<CString>::iterator iter = m_historyCommand.begin();
	for(; iter != m_historyCommand.end(); iter++)
	{
		if(i == 0)
		{
			CString output = L"";
			CString output1 = L"";
			AfxExtractSubString(output, (*iter), 0, _T(':'));
			AfxExtractSubString(output1, (*iter), 1, _T(':'));

			char* ip = KBEngine::strutil::wchar2char(output.GetBuffer(0));
			m_ip.SetAddress(ntohl(inet_addr(ip)));
			free(ip);

			m_port.SetWindowTextW(output1);
		}

		i++;
		m_log.AddString((*iter));
	}

	return TRUE;  // return TRUE  unless you set the focus to a control
}
Ejemplo n.º 3
0
bool V3DocViewWin::loadHistory( lString16 filename )
{
	CRLog::trace("V3DocViewWin::loadHistory( %s )", UnicodeToUtf8(filename).c_str());
    _historyFileName = filename;
    LVStreamRef stream = LVOpenFileStream( filename.c_str(), LVOM_READ );
    return loadHistory( stream );
}
Ejemplo n.º 4
0
void initDimmunix() {
	histSize = 0;
	init_Cycle(&cycle);
	init_Cycle(&stack);
	joinPointFound = NULL;
	blocked = false;

	nSyncs = 0;
	nSyncThreads = 0;
	nYields = 0;

	pthread_mutex_init(&avoidanceLock, NULL);

    if((positions=(struct Queue*)malloc_zero(sizeof(struct Queue)*MAXPOSITIONS))==NULL){
        LOGD("ERROR ALLOCATING DIMMUNIX positions");
    }
    if((history=(struct Template*)malloc_zero(sizeof(struct Template)*MAXTEMPLATES))==NULL){
        LOGD("ERROR ALLOCATING DIMMUNIX history");
    }

    int i;
    for (i = 0; i < MAXPOSITIONS; i++) {
    	initQueue(&positions[i]);
    }

	loadHistory();

//	pthread_create(&monitorThread, NULL, printStats, NULL);

	enabled = true;

	LOGD("initialized Dimmunix");
}
Ejemplo n.º 5
0
Dialog::Dialog(const Application* application, const QString& userId, QWidget* parent) :
    QWidget(parent),
    ui(new Ui::Dialog),
    application(application),
    userId(userId)
{
    unreadInList = QStringList();
    setupUi();

    connect(ui->textEdit
            , SIGNAL(focusIn())
            , this
            , SLOT(markInboxRead()));


    connect(ui->webView->page()->mainFrame()
            , SIGNAL(contentsSizeChanged(QSize))
            , this
            , SLOT(scrollToBottom(QSize)));

    loadHistory(20);

    connect(&application->getLongPollExecutor()
            , SIGNAL(messageRecieved(QString,bool, bool,QString,uint,QString))
            , this
            , SLOT(insertMessage(QString,bool, bool,QString,uint,QString)));
    connect(&application->getLongPollExecutor()
            , SIGNAL(messageIsRead(QString))
            , this
            , SLOT(markMessageIsRead(QString)));
    connect(ui->textEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage()));
    connect(ui->pushButton, SIGNAL(released()), this, SLOT(sendMessage()));
    ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    connect(ui->webView, SIGNAL(linkClicked(QUrl)), this, SLOT(openAttachment(QUrl)));
}
Ejemplo n.º 6
0
DebugTools::DebugTools(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DebugTools)
{
    ui->setupUi(this);

    connect(ui->sendPacketBtn, SIGNAL(clicked(bool)), this, SLOT(sendPacket()));
    connect(ui->historyListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(sentHistoryListItemClicked()));
    connect(ui->historyListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(sentHistoryListItemDoubleClicked()));

    connect(ui->clearBtn, SIGNAL(clicked(bool)), this, SLOT(clear()));

    ui->packetLineEdit->installEventFilter( this );

    QList<int> sizes;
    sizes << 150 << 50;
    ui->splitter->setSizes(sizes);
    connect(ui->examplesTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(exampleItemSelected()));


    loadHistory();

    ui->historyListWidget->scrollToBottom();
    ui->historyListWidget->setCurrentRow( ui->historyListWidget->count() - 1 );
}
Ejemplo n.º 7
0
void 
TestPlugInRunnerModel::reloadPlugIn()
{
  try 
  {
    CWaitCursor waitCursor;
    m_history.clear();
    freeRootTest();
    setRootTest( m_plugIn->makeTest() );

    loadHistory();
  }
  catch (...)
  {
    setRootTest( new CPPUNIT_NS::TestSuite( "Default" ) );  
    loadHistory();
    throw;
  }
}
Ejemplo n.º 8
0
void ChatForm::onLoadHistory()
{
    LoadHistoryDialog dlg;

    if (dlg.exec())
    {
        QDateTime fromTime = dlg.getFromDate();
        loadHistory(fromTime);
    }
}
Ejemplo n.º 9
0
void HistoryForm::show()
{
    if (isVisible()) {
		raise();
        activateWindow();
		return;
	}
	
	loadHistory();
	QDialog::show();
	raise();
}
Ejemplo n.º 10
0
void ChatForm::onLoadHistory()
{
    if (!Nexus::getProfile()->isHistoryEnabled())
        return;

    LoadHistoryDialog dlg;

    if (dlg.exec())
    {
        QDateTime fromTime = dlg.getFromDate();
        loadHistory(fromTime);
    }
}
Ejemplo n.º 11
0
int main(){

char path[MAX];
	strcpy(path, getenv("PATH"));
	strcpy(home, getenv("HOME"));
	 
loadHistory();
	chdir(home);
	printf("PATH :%s\n",(path!=NULL)? path : "getenv returned NULL");	
	printf("Home: %s\n ",home); 	
	getInput();
	return(0);
}
Ejemplo n.º 12
0
DialPanel::DialPanel(QWidget *parent)
    : XLet(parent)
{
    setTitle(tr("Dial"));
    setAccessibleName(tr("Dial Panel"));

    setAcceptDrops(true);

    m_input = new QComboBox(this);
    m_input->setObjectName("extension_input");
    m_input->setToolTip(tr("Input here the phone number to dial"));
    m_input->setEditable(true);
    m_input->setDuplicatesEnabled(false);
    m_input->setInsertPolicy(QComboBox::InsertAtTop);
    m_input->setMinimumContentsLength(15);
    m_input->lineEdit()->setMaxLength(30);

    m_lbl = new QLabel(tr("Enter &Number :"), this);
    m_lbl->setBuddy(m_input);

    loadHistory();
    m_input->clearEditText();

    QPixmap pmphone = QPixmap(":/images/sipphone.png");
    QPushButton * dialButton = new QPushButton(this);
    dialButton->setObjectName("dial_button");
    dialButton->setIcon(pmphone);
    dialButton->setIconSize(pmphone.size());

    QHBoxLayout * vlayout = new QHBoxLayout(this);
    vlayout->setMargin(0);
    vlayout->addStretch(1);
    vlayout->addWidget(m_lbl, 0, Qt::AlignCenter);
    vlayout->addWidget(m_input, 0, Qt::AlignCenter);
    vlayout->addWidget(dialButton, 0, Qt::AlignCenter);
    vlayout->addStretch(1);

    connect(dialButton, SIGNAL(clicked()),
            m_input->lineEdit(), SIGNAL(returnPressed()));
    connect(b_engine, SIGNAL(pasteToXlets(const QString &)),
            this, SLOT(setNumberToDial(const QString &)));
    connect(this, SIGNAL(textEdited(const QString &)),
            b_engine, SLOT(textEdited(const QString &)));
    connect(m_input->lineEdit(), SIGNAL(returnPressed()),
            this, SLOT(inputValidated()));
    connect(m_input, SIGNAL(editTextChanged(const QString &)),
            this, SIGNAL(textEdited(const QString &)));
}
Ejemplo n.º 13
0
KonqHistoryManager::KonqHistoryManager(KBookmarkManager *bookmarkManager, QObject *parent)
    : KonqHistoryProvider(parent),
      m_bookmarkManager(bookmarkManager)
{
    m_updateTimer = new QTimer(this);

    // take care of the completion object
    m_pCompletion = new KCompletion;
    m_pCompletion->setOrder(KCompletion::Weighted);

    // and load the history
    loadHistory();

    connect(m_updateTimer, &QTimer::timeout, this, &KonqHistoryManager::slotEmitUpdated);
    connect(this, &KonqHistoryManager::cleared, this, &KonqHistoryManager::slotCleared);
    connect(this, &KonqHistoryManager::entryRemoved, this, &KonqHistoryManager::slotEntryRemoved);
}
Ejemplo n.º 14
0
void 
TestRunnerModel::loadSettings(Settings & s)
{
  CWinApp *app = AfxGetApp();
  ASSERT( app != NULL );

  int autorun = app->GetProfileInt( _T("CppUnit"),
                                    _T("AutorunAtStartup"),
                                    1 );
  s.autorunOnLaunch = (autorun == 1);

  s.col_1 = app->GetProfileInt( _T("CppUnit"), _T("Col_1"), 40 );
  s.col_2 = app->GetProfileInt( _T("CppUnit"), _T("Col_2"), 40 );
  s.col_3 = app->GetProfileInt( _T("CppUnit"), _T("Col_3"), 40 );
  s.col_4 = app->GetProfileInt( _T("CppUnit"), _T("Col_4"), 40 );

  loadHistory();
}
Ejemplo n.º 15
0
void ZhscWidget::init()
{
  if ( bConStatus ) 
  {
    loadHistory();

    buildCBDynasty();
    buildCBPoet();
    buildCBPoem();
    buildTEPoet();
    buildTEPoem();

    setPoem();

    record();

    bookmark();
  }
}
Ejemplo n.º 16
0
void FSFloaterNearbyChat::reloadMessages(bool clean_messages/* = false*/)
{
	if (clean_messages)
	{
		mMessageArchive.clear();
		loadHistory();
	}
	
	mChatHistory->clear();
	mChatHistoryMuted->clear();
	
	LLSD do_not_log;
	do_not_log["do_not_log"] = true;
	for(std::vector<LLChat>::iterator it = mMessageArchive.begin();it!=mMessageArchive.end();++it)
	{
		// Update the messages without re-writing them to a log file.
		addMessage(*it,false, do_not_log);
	}
}
Ejemplo n.º 17
0
/**
  * SLOT
  * Load songs from playlist
  * selected in QTreeView ui->tvPlaylists
  */
void MainWindow::loadPlaylist()
{
    QStandardItemModel *model = (QStandardItemModel*)ui->tvPlaylists->model();
    QStandardItem *item = model->itemFromIndex(ui->tvPlaylists->selectionModel()->currentIndex());
    int data = item->data(DATA_KEY_PLAYLIST).toInt();

    switch(data) {
        case DATA_SEARCH:
            loadSearchResults();
            break;
        case DATA_EMPTY:
            break; // do nothing
        case DATA_HISTORY:
            loadHistory();
            break;
        default:
            loadPlaylist(data);
            break;
    }
}
Ejemplo n.º 18
0
KeyAddDialog::KeyAddDialog( CryptoDoc *_doc, QWidget *parent )
:	QWidget( parent )
,	doc( _doc )
{
	setupUi( this );
	setAttribute( Qt::WA_DeleteOnClose );
	setWindowFlags( Qt::Dialog );

	cardButton = buttonBox->addButton( tr("Add cert from card"), QDialogButtonBox::ActionRole );
	connect( cardButton, SIGNAL(clicked()), SLOT(addCardCert()) );
	connect( buttonBox->addButton( tr("Add cert from file"), QDialogButtonBox::ActionRole ),
		SIGNAL(clicked()), SLOT(addFile()) );
	connect( qApp, SIGNAL(dataChanged()), SLOT(enableCardCert()) );
	enableCardCert();

	skView->setModel( keyModel = new KeyModel( this ) );
	skView->header()->setStretchLastSection( false );
	skView->header()->setResizeMode( 0, QHeaderView::Stretch );
	skView->header()->setResizeMode( 1, QHeaderView::ResizeToContents );
	skView->header()->setResizeMode( 2, QHeaderView::ResizeToContents );
	connect( skView, SIGNAL(doubleClicked(QModelIndex)), SLOT(on_add_clicked()) );

	usedView->header()->setStretchLastSection( false );
	usedView->header()->setResizeMode( 0, QHeaderView::Stretch );
	usedView->header()->setResizeMode( 1, QHeaderView::ResizeToContents );
	usedView->header()->setResizeMode( 2, QHeaderView::ResizeToContents );
	loadHistory();

	ldap = new LdapSearch( this );
	connect( ldap, SIGNAL(searchResult(QList<CKey>)), SLOT(showResult(QList<CKey>)) );
	connect( ldap, SIGNAL(error(QString)), SLOT(showError(QString)) );

	validator = new IKValidator( this );
	on_searchType_currentIndexChanged( 0 );
	add->setEnabled( false );
	progress->setVisible( false );
}
Ejemplo n.º 19
0
void QLineEditEx::suggest(bool up)
{
	if(m_TabBase.isEmpty())
		m_TabBase = text();
	if(m_TabBase.isEmpty())
		return;

	int Length = m_TabBase.length();

	QStringList Suggestions;
	foreach(QString Line, m_History)
	{
		if(Line.left(Length).compare(m_TabBase, Qt::CaseInsensitive) == 0)
		{
			int Pos = Line.indexOf(" ", Length);
			if(Pos != -1)
				Line.truncate(Pos);
			if(!Suggestions.contains(Line))
				Suggestions.append(Line);
		}
	}

	loadHistory(up,Suggestions,m_TabIndex);
}
Ejemplo n.º 20
0
CHoloPropagLargeEditor::CHoloPropagLargeEditor(const QString & hist_file, QWidget *parent)
  : QWidget(parent),
    m_HoloPropagLarge_proc(),
    m_caption(0),
    m_cfg_file(0),
    m_binary_file(0),
    m_pb_run(0),
    m_pb_reload(0),
    m_pb_save(0),
    m_HoloPropagLarge_output(0),
    m_entry_Lambda(0),
    m_entry_Pitch(0),
    m_entry_ForceSettings(0),
    m_entry_RandomizePhase(0),
    m_entry_ImageContainsIntensity(0),
    m_entry_ImageContainsAmplitude(0),
    m_entry_ImageContainsPhase(0),
    m_entry_Input(0),
    m_entry_Target(0),
    m_entry_ImageIntensityMaximum(0),
    m_entry_ImageIntensityMinimum(0),
    m_entry_Frame(0),
    m_entry_FrameX(0),
    m_entry_FrameY(0),
    m_entry_FrameRemove(0),
    m_entry_Operations(0)
{
  /* set up DFtoHologram process */
  m_HoloPropagLarge_proc.setProcessChannelMode(QProcess::MergedChannels);  // redirect stderr to stdout
  connect(&m_HoloPropagLarge_proc, SIGNAL(readyReadStandardOutput()), SLOT(handleStdoutRead()));
  connect(&m_HoloPropagLarge_proc, SIGNAL(error(QProcess::ProcessError)), SLOT(handleProcessError(QProcess::ProcessError)));
  connect(&m_HoloPropagLarge_proc, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(handleProcessFinished(int, QProcess::ExitStatus)));

  /* create UI */
  m_caption = new QLabel(tr("HoloPropagLarge Editor"));
  m_caption->setAlignment(Qt::AlignCenter);
  m_caption->setStyleSheet("font-size: 16px; font-weight: bold;");

  m_HoloPropagLarge_output = new QTextEdit;

  QVBoxLayout *vl = new QVBoxLayout;
  vl->addSpacing(20);
  vl->addWidget(m_caption);
  vl->addSpacing(30);
  vl->addWidget(createSystemInfo());
  vl->addWidget(createGroupEntries());
  vl->addWidget(createGroupImageContains());
  vl->addWidget(createGroupFrame());
  vl->addWidget(createGroupOperations());
  vl->addWidget(m_HoloPropagLarge_output, 1);
  vl->addLayout(createButtons());
  setLayout(vl);

  if (!hist_file.isNull())
  {
    /* reload the config' history */
    loadHistory(hist_file);

    /* realod the first config file */
    reload();
  }

  /* connect a signal for automatic reloading each time a
     new config is picked */
  connect(m_cfg_file, SIGNAL(picked()), SLOT(reload()));
}
Ejemplo n.º 21
0
KfindTabWidget::KfindTabWidget(TQWidget *parent, const char *name)
  : TQTabWidget( parent, name ), regExpDialog(0)
{
    // This validator will be used for all numeric edit fields
    //KDigitValidator *digitV = new KDigitValidator(this);

    // ************ Page One ************

    pages[0] = new TQWidget( this, "page1" );

    nameBox = new KComboBox(TRUE, pages[0], "combo1");
    nameBox->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed);  // allow smaller than widest entry
    TQLabel * namedL = new TQLabel(nameBox, i18n("&Named:"), pages[0], "named");
    TQToolTip::add( namedL, i18n("You can use wildcard matching and \";\" for separating multiple names") );
    dirBox  = new KComboBox(TRUE, pages[0], "combo2");
    dirBox->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed);  // allow smaller than widest entry
    TQLabel * lookinL = new TQLabel(dirBox, i18n("Look &in:"), pages[0], "named");
    subdirsCb  = new TQCheckBox(i18n("Include &subfolders"), pages[0]);
    caseSensCb  = new TQCheckBox(i18n("Case s&ensitive search"), pages[0]);
    browseB    = new TQPushButton(i18n("&Browse..."), pages[0]);
    useLocateCb = new TQCheckBox(i18n("&Use files index"), pages[0]);

    // Setup

    subdirsCb->setChecked(true);
    caseSensCb->setChecked(false);
    useLocateCb->setChecked(false);
    if(TDEStandardDirs::findExe("locate")==NULL)
    	useLocateCb->setEnabled(false);

    nameBox->setDuplicatesEnabled(FALSE);
    nameBox->setFocus();
    dirBox->setDuplicatesEnabled(FALSE);

    nameBox->setInsertionPolicy(TQComboBox::AtTop);
    dirBox->setInsertionPolicy(TQComboBox::AtTop);

    const TQString nameWhatsThis
      = i18n("<qt>Enter the filename you are looking for. <br>"
	     "Alternatives may be separated by a semicolon \";\".<br>"
	     "<br>"
	     "The filename may contain the following special characters:"
	     "<ul>"
	     "<li><b>?</b> matches any single character</li>"
	     "<li><b>*</b> matches zero or more of any characters</li>"
	     "<li><b>[...]</b> matches any of the characters in braces</li>"
	     "</ul>"
	     "<br>"
	     "Example searches:"
	     "<ul>"
	     "<li><b>*.kwd;*.txt</b> finds all files ending with .kwd or .txt</li>"
	     "<li><b>go[dt]</b> finds god and got</li>"
	     "<li><b>Hel?o</b> finds all files that start with \"Hel\" and end with \"o\", "
	     "having one character in between</li>"
	     "<li><b>My Document.kwd</b> finds a file of exactly that name</li>"
	     "</ul></qt>");
    TQWhatsThis::add(nameBox,nameWhatsThis);
    TQWhatsThis::add(namedL,nameWhatsThis);
    const TQString whatsfileindex
        = i18n("<qt>This lets you use the files' index created by the <i>slocate</i> "
               "package to speed-up the search; remember to update the index from time to time "
               "(using <i>updatedb</i>)."
               "</qt>");
    TQWhatsThis::add(useLocateCb,whatsfileindex);

    // Layout

    TQGridLayout *grid = new TQGridLayout( pages[0], 3, 2,
					 KDialog::marginHint(),
					 KDialog::spacingHint() );
    TQBoxLayout *subgrid = new TQVBoxLayout( -1 , "subgrid" );
    grid->addWidget( namedL, 0, 0 );
    grid->addMultiCellWidget( nameBox, 0, 0, 1, 2 );
    grid->addWidget( lookinL, 1, 0 );
    grid->addWidget( dirBox, 1, 1 );
    grid->addWidget( browseB, 1, 2);
    grid->setColStretch(1,1);
    grid->addMultiCellLayout( subgrid, 2, 2, 1, 2 );
    subgrid->addWidget( subdirsCb );
    subgrid->addWidget( caseSensCb);
    subgrid->addWidget( useLocateCb );
    subgrid->addStretch(1);

    // Signals

    connect( browseB, TQT_SIGNAL(clicked()),
             this, TQT_SLOT(getDirectory()) );

    connect( nameBox, TQT_SIGNAL(activated(int)),
             this, TQT_SIGNAL(startSearch()));

    // ************ Page Two

    pages[1] = new TQWidget( this, "page2" );

    findCreated =  new TQCheckBox(i18n("Find all files created or &modified:"), pages[1]);
    bg  = new TQButtonGroup();
    rb[0] = new TQRadioButton(i18n("&between"), pages[1] );
    rb[1] = new TQRadioButton(i18n("&during the previous"), pages[1] );
    TQLabel * andL   = new TQLabel(i18n("and"), pages[1], "and");
    betweenType = new KComboBox(FALSE, pages[1], "comboBetweenType");
    betweenType->insertItem(i18n("minute(s)"));
    betweenType->insertItem(i18n("hour(s)"));
    betweenType->insertItem(i18n("day(s)"));
    betweenType->insertItem(i18n("month(s)"));
    betweenType->insertItem(i18n("year(s)"));
    betweenType->setCurrentItem(1);


    TQDate dt = TDEGlobal::locale()->calendar()->addYears(TQDate::currentDate(), -1);

    fromDate = new KDateCombo(dt, pages[1], "fromDate");
    toDate = new KDateCombo(pages[1], "toDate");
    timeBox = new TQSpinBox(1, 60, 1, pages[1], "timeBox");

    sizeBox =new KComboBox(FALSE, pages[1], "sizeBox");
    TQLabel * sizeL   =new TQLabel(sizeBox,i18n("File &size is:"), pages[1],"size");
    sizeEdit=new TQSpinBox(0, INT_MAX, 1, pages[1], "sizeEdit" );
    sizeEdit->setValue(1);
    sizeUnitBox =new KComboBox(FALSE, pages[1], "sizeUnitBox");

    m_usernameBox = new KComboBox( true, pages[1], "m_combo1");
    TQLabel *usernameLabel= new TQLabel(m_usernameBox,i18n("Files owned by &user:"******"m_combo2");
    TQLabel *groupLabel= new TQLabel(m_groupBox,i18n("Owned by &group:"),pages[1]);

    sizeBox ->insertItem( i18n("(none)") );
    sizeBox ->insertItem( i18n("At Least") );
    sizeBox ->insertItem( i18n("At Most") );
    sizeBox ->insertItem( i18n("Equal To") );

    sizeUnitBox ->insertItem( i18n("Bytes") );
    sizeUnitBox ->insertItem( i18n("KB") );
    sizeUnitBox ->insertItem( i18n("MB") );
    sizeUnitBox ->insertItem( i18n("GB") );
    sizeUnitBox ->setCurrentItem(1);

    int tmp = sizeEdit->fontMetrics().width(" 000000000 ");
    sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height());

    m_usernameBox->setDuplicatesEnabled(FALSE);
    m_groupBox->setDuplicatesEnabled(FALSE);
    m_usernameBox->setInsertionPolicy(TQComboBox::AtTop);
    m_groupBox->setInsertionPolicy(TQComboBox::AtTop);


    // Setup
    timeBox->setButtonSymbols(TQSpinBox::PlusMinus);
    rb[0]->setChecked(true);
    bg->insert( rb[0] );
    bg->insert( rb[1] );

    // Layout

    TQGridLayout *grid1 = new TQGridLayout( pages[1], 5,  6,
					  KDialog::marginHint(),
					  KDialog::spacingHint() );

    grid1->addMultiCellWidget(findCreated, 0, 0, 0, 3 );
    grid1->addColSpacing(0, KDialog::spacingHint());

    grid1->addWidget(rb[0], 1, 1 );
    grid1->addWidget(fromDate, 1, 2 );
    grid1->addWidget(andL, 1, 3, Qt::AlignHCenter );
    grid1->addWidget(toDate, 1, 4 );

    grid1->addWidget(rb[1], 2, 1 );
    grid1->addMultiCellWidget(timeBox, 2, 2, 2, 3);
    grid1->addWidget(betweenType, 2, 4 );

    grid1->addMultiCellWidget(sizeL,3,3,0,1);
    grid1->addWidget(sizeBox,3,2);
    grid1->addWidget(sizeEdit,3,3);
    grid1->addWidget(sizeUnitBox,3,4);

    grid1->addMultiCellWidget(usernameLabel,4,4,0,1);
    grid1->addWidget(m_usernameBox,4,2);
    grid1->addWidget(groupLabel,4,3);
    grid1->addWidget(m_groupBox,4,4);

    for (int c=1; c<=4; c++)
       grid1->setColStretch(c,1);

    grid1->setRowStretch(6,1);

    // Connect
    connect( findCreated,  TQT_SIGNAL(toggled(bool)),   TQT_SLOT(fixLayout()) );
    connect( bg,  TQT_SIGNAL(clicked(int)), this,   TQT_SLOT(fixLayout()) );
    connect( sizeBox, TQT_SIGNAL(highlighted(int)), this, TQT_SLOT(slotSizeBoxChanged(int)));


    // ************ Page Three

    pages[2] = new TQWidget( this, "page3" );

    typeBox =new KComboBox(FALSE, pages[2], "typeBox");
    typeBox->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed);  // allow smaller than widest entry
    TQLabel * typeL   =new TQLabel(typeBox, i18n("File &type:"), pages[2], "type");
    textEdit=new KLineEdit(pages[2], "textEdit" );
    TQLabel * textL   =new TQLabel(textEdit, i18n("C&ontaining text:"), pages[2], "text");

    connect( textEdit, TQT_SIGNAL(returnPressed(const TQString &)), TQT_SIGNAL( startSearch()));

    const TQString containingtext
      = i18n("<qt>If specified, only files that contain this text"
	      " are found. Note that not all file types from the list"
		  " above are supported. Please refer to the documentation"
		  " for a list of supported file types."
	      "</qt>");
    TQToolTip::add(textEdit,containingtext);
    TQWhatsThis::add(textL,containingtext);

    caseContextCb  =new TQCheckBox(i18n("Case s&ensitive"), pages[2]);
    binaryContextCb  =new TQCheckBox(i18n("Include &binary files"), pages[2]);
    regexpContentCb  =new TQCheckBox(i18n("Regular e&xpression"), pages[2]);

    const TQString binaryTooltip
      = i18n("<qt>This lets you search in any type of file, "
       "even those that usually do not contain text (for example "
	   "program files and images).</qt>");
    TQToolTip::add(binaryContextCb,binaryTooltip);

    TQPushButton* editRegExp = 0;
    if ( !TDETrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty() ) {
      // The editor is available, so lets use it.
      editRegExp = new TQPushButton(i18n("&Edit..."), pages[2], "editRegExp");
    }

    metainfokeyEdit=new KLineEdit(pages[2], "textEdit" );
    metainfoEdit=new KLineEdit(pages[2], "textEdit" );
    TQLabel * textMetaInfo = new TQLabel(metainfoEdit, i18n("fo&r:"), pages[2], "text");
    TQLabel * textMetaKey = new TQLabel(metainfokeyEdit, i18n("Search &metainfo sections:"), pages[2], "text");

    // Setup
    typeBox->insertItem(i18n("All Files & Folders"));
    typeBox->insertItem(i18n("Files"));
    typeBox->insertItem(i18n("Folders"));
    typeBox->insertItem(i18n("Symbolic Links"));
    typeBox->insertItem(i18n("Special Files (Sockets, Device Files, ...)"));
    typeBox->insertItem(i18n("Executable Files"));
    typeBox->insertItem(i18n("SUID Executable Files"));
    typeBox->insertItem(i18n("All Images"));
    typeBox->insertItem(i18n("All Video"));
    typeBox->insertItem(i18n("All Sounds"));

    initMimeTypes();
    initSpecialMimeTypes();

    for ( KMimeType::List::ConstIterator it = m_types.begin();
          it != m_types.end(); ++it )
    {
      KMimeType::Ptr typ = *it;
      typeBox->insertItem(typ->pixmap( TDEIcon::Small ), typ->comment());
    }

    if ( editRegExp ) {
      // The editor was available, so lets use it.
      connect( regexpContentCb, TQT_SIGNAL(toggled(bool) ), editRegExp, TQT_SLOT(setEnabled(bool)) );
      editRegExp->setEnabled(false);
      connect( editRegExp, TQT_SIGNAL(clicked()), this, TQT_SLOT( slotEditRegExp() ) );
    }
    else
        regexpContentCb->hide();

    // Layout
    tmp = sizeEdit->fontMetrics().width(" 00000 ");
    sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height());

    TQGridLayout *grid2 = new TQGridLayout( pages[2], 5, 4,
					  KDialog::marginHint(),
					  KDialog::spacingHint() );
    grid2->addWidget( typeL, 0, 0 );
    grid2->addWidget( textL, 1, 0 );
    grid2->addMultiCellWidget( typeBox, 0, 0, 1, 3 );
    grid2->addMultiCellWidget( textEdit, 1, 1, 1, 3 );
    grid2->addWidget( regexpContentCb, 2, 2);
    grid2->addWidget( caseContextCb, 2, 1 );
    grid2->addWidget( binaryContextCb, 3, 1);

    grid2->addWidget( textMetaKey, 4, 0 );
    grid2->addWidget( metainfokeyEdit, 4, 1 );
    grid2->addWidget( textMetaInfo, 4, 2, Qt::AlignHCenter  );
    grid2->addWidget( metainfoEdit, 4, 3 );

    metainfokeyEdit->setText("*");

    if ( editRegExp ) {
      // The editor was available, so lets use it.
      grid2->addWidget( editRegExp, 2, 3 );
    }

    addTab( pages[0], i18n("Name/&Location") );
    addTab( pages[2], i18n("C&ontents") );
    addTab( pages[1], i18n("&Properties") );


    // Setup
    const TQString whatsmetainfo
      = i18n("<qt>Search within files' specific comments/metainfo<br>"
	     "These are some examples:<br>"
	     "<ul>"
	     "<li><b>Audio files (mp3...)</b> Search in id3 tag for a title, an album</li>"
	     "<li><b>Images (png...)</b> Search images with a special resolution, comment...</li>"
	     "</ul>"
	     "</qt>");
    const TQString whatsmetainfokey
      = i18n("<qt>If specified, search only in this field<br>"
	     "<ul>"
	     "<li><b>Audio files (mp3...)</b> This can be Title, Album...</li>"
	     "<li><b>Images (png...)</b> Search only in Resolution, Bitdepth...</li>"
	     "</ul>"
	     "</qt>");
    TQWhatsThis::add(textMetaInfo,whatsmetainfo);
    TQToolTip::add(metainfoEdit,whatsmetainfo);
    TQWhatsThis::add(textMetaKey,whatsmetainfokey);
    TQToolTip::add(metainfokeyEdit,whatsmetainfokey);


    fixLayout();
    loadHistory();
}
Ejemplo n.º 22
0
KfindTabWidget::KfindTabWidget(QWidget *parent)
  : KTabWidget( parent ), regExpDialog(0)
{
    // This validator will be used for all numeric edit fields
    //KDigitValidator *digitV = new KDigitValidator(this);

    // ************ Page One ************

    pages[0] = new QWidget;
    pages[0]->setObjectName( QLatin1String( "page1" ) );

    nameBox = new KComboBox(pages[0]);
    nameBox->setEditable( true );
    nameBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);  // allow smaller than widest entry
    QLabel * namedL = new QLabel(i18nc("this is the label for the name textfield","&Named:"), pages[0]);
    namedL->setBuddy( nameBox );
    namedL->setObjectName( QLatin1String( "named" ) );
    namedL->setToolTip( i18n("You can use wildcard matching and \";\" for separating multiple names") );
    dirBox  = new KUrlComboBox(KUrlComboBox::Directories, pages[0]);
    dirBox->setEditable( true );
    dirBox->setCompletionObject(new KUrlCompletion(KUrlCompletion::DirCompletion));
    dirBox->setAutoDeleteCompletionObject(true);
    dirBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);  // allow smaller than widest entry
    QLabel * lookinL = new QLabel(i18n("Look &in:"), pages[0]);
    lookinL->setBuddy( dirBox );
    lookinL->setObjectName( QLatin1String( "lookin" ) );
    subdirsCb  = new QCheckBox(i18n("Include &subfolders"), pages[0]);
    caseSensCb  = new QCheckBox(i18n("Case s&ensitive search"), pages[0]);
    browseB    = new QPushButton(i18n("&Browse..."), pages[0]);
    useLocateCb = new QCheckBox(i18n("&Use files index"), pages[0]);
    hiddenFilesCb = new QCheckBox(i18n("Show &hidden files"), pages[0]);
    // Setup

    subdirsCb->setChecked(true);
    caseSensCb->setChecked(false);
    useLocateCb->setChecked(false);
    hiddenFilesCb->setChecked(false);
    if(KStandardDirs::findExe(QLatin1String("locate")).isEmpty())
        useLocateCb->setEnabled(false);

    nameBox->setDuplicatesEnabled(false);
    nameBox->setFocus();
    dirBox->setDuplicatesEnabled(false);

    nameBox->setInsertPolicy(QComboBox::InsertAtTop);
    dirBox->setInsertPolicy(QComboBox::InsertAtTop);

    const QString nameWhatsThis
      = i18n("<qt>Enter the filename you are looking for. <br />"
	     "Alternatives may be separated by a semicolon \";\".<br />"
	     "<br />"
	     "The filename may contain the following special characters:"
	     "<ul>"
	     "<li><b>?</b> matches any single character</li>"
	     "<li><b>*</b> matches zero or more of any characters</li>"
	     "<li><b>[...]</b> matches any of the characters between the braces</li>"
	     "</ul>"
	     "<br />"
	     "Example searches:"
	     "<ul>"
	     "<li><b>*.kwd;*.txt</b> finds all files ending with .kwd or .txt</li>"
	     "<li><b>go[dt]</b> finds god and got</li>"
	     "<li><b>Hel?o</b> finds all files that start with \"Hel\" and end with \"o\", "
	     "having one character in between</li>"
	     "<li><b>My Document.kwd</b> finds a file of exactly that name</li>"
	     "</ul></qt>");
    nameBox->setWhatsThis(nameWhatsThis);
    namedL->setWhatsThis(nameWhatsThis);
    const QString whatsfileindex
        = i18n("<qt>This lets you use the files' index created by the <i>slocate</i> "
               "package to speed-up the search; remember to update the index from time to time "
               "(using <i>updatedb</i>)."
               "</qt>");
    useLocateCb->setWhatsThis(whatsfileindex);

    // Layout

    QGridLayout *grid = new QGridLayout( pages[0] );
    grid->setMargin( KDialog::marginHint() );
    grid->setSpacing( KDialog::spacingHint() );
    QVBoxLayout *subgrid = new QVBoxLayout();
    grid->addWidget( namedL, 0, 0 );
    grid->addWidget( nameBox, 0, 1, 1, 3 );
    grid->addWidget( lookinL, 1, 0 );
    grid->addWidget( dirBox, 1, 1 );
    grid->addWidget( browseB, 1, 2);
    grid->setColumnStretch(1,1);
    grid->addLayout( subgrid, 2, 1, 1, 2 );
    
    QHBoxLayout * layoutOne = new QHBoxLayout();
    layoutOne->addWidget( subdirsCb );
    layoutOne->addWidget( hiddenFilesCb );
    
    QHBoxLayout * layoutTwo = new QHBoxLayout();
    layoutTwo->addWidget( caseSensCb);
    layoutTwo->addWidget( useLocateCb );
    
    subgrid->addLayout( layoutOne );
    subgrid->addLayout( layoutTwo );
    
    subgrid->addStretch(1);

    // Signals

    connect(browseB, &QPushButton::clicked, this, &KfindTabWidget::getDirectory);

    connect(nameBox, static_cast<void (KComboBox::*)()>(&KComboBox::returnPressed), this, &KfindTabWidget::startSearch);

    connect(dirBox, static_cast<void (KUrlComboBox::*)()>(&KUrlComboBox::returnPressed), this, &KfindTabWidget::startSearch);
    
    // ************ Page Two

    pages[1] = new QWidget;
    pages[1]->setObjectName( QLatin1String( "page2" ) );

    findCreated =  new QCheckBox(i18n("Find all files created or &modified:"), pages[1]);
    bg  = new QButtonGroup();
    rb[0] = new QRadioButton(i18n("&between"), pages[1] );
    rb[1] = new QRadioButton(pages[1]); // text set in updateDateLabels
    andL = new QLabel(i18n("and"), pages[1]);
    andL->setObjectName( QLatin1String( "and" ) );
    betweenType = new KComboBox( pages[1] );
    betweenType->setObjectName( QLatin1String( "comboBetweenType" ) );
    betweenType->addItems(QVector<QString>(5).toList()); // texts set in updateDateLabels
    betweenType->setCurrentIndex(1);
    updateDateLabels(1, 1);

    QDate dt = KLocale::global()->calendar()->addYears(QDate::currentDate(), -1);

    fromDate = new KDateCombo(dt, pages[1] );
    fromDate->setObjectName( QLatin1String( "fromDate" ) );
    toDate = new KDateCombo(pages[1] );
    toDate->setObjectName( QLatin1String( "toDate" ) );
    timeBox = new KIntSpinBox( pages[1] );
    timeBox->setRange( 1, 60 );
    timeBox->setSingleStep( 1 );
    timeBox->setObjectName( QLatin1String( "timeBox" ) );

    sizeBox =new KComboBox( pages[1] );
    sizeBox->setObjectName( QLatin1String( "sizeBox" ) );
    QLabel * sizeL   =new QLabel(i18n("File &size is:"), pages[1]);
    sizeL->setBuddy( sizeBox );
    sizeEdit=new KIntSpinBox(pages[1] );
    sizeEdit->setRange( 0, INT_MAX );
    sizeEdit->setSingleStep( 1 );
    sizeEdit->setObjectName( QLatin1String( "sizeEdit" ) );
    sizeEdit->setValue(1);
    sizeUnitBox =new KComboBox( pages[1] );
    sizeUnitBox->setObjectName( QLatin1String( "sizeUnitBox" ) );

    m_usernameBox = new KComboBox( pages[1] );
    m_usernameBox->setEditable( true );
    m_usernameBox->setObjectName( QLatin1String( "m_combo1" ));
    QLabel *usernameLabel= new QLabel(i18n("Files owned by &user:"******"m_combo2" ) );
    QLabel *groupLabel= new QLabel(i18n("Owned by &group:"),pages[1]);
    groupLabel->setBuddy( m_groupBox );

    sizeBox ->addItem( i18nc("file size isn't considered in the search","(none)") );
    sizeBox ->addItem( i18n("At Least") );
    sizeBox ->addItem( i18n("At Most") );
    sizeBox ->addItem( i18n("Equal To") );

    sizeUnitBox ->addItem( i18np("Byte", "Bytes", 1) );
    sizeUnitBox ->addItem( i18n("KiB") );
    sizeUnitBox ->addItem( i18n("MiB") );
    sizeUnitBox ->addItem( i18n("GiB") );
    sizeUnitBox ->setCurrentIndex(1);

    int tmp = sizeEdit->fontMetrics().width(QLatin1String(" 000000000 "));
    sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height());

    m_usernameBox->setDuplicatesEnabled(false);
    m_groupBox->setDuplicatesEnabled(false);
    m_usernameBox->setInsertPolicy(QComboBox::InsertAtTop);
    m_groupBox->setInsertPolicy(QComboBox::InsertAtTop);


    // Setup
    rb[0]->setChecked(true);
    bg->addButton( rb[0] );
    bg->addButton( rb[1] );

    // Layout

    QGridLayout *grid1 = new QGridLayout( pages[1] );
    grid1->setMargin( KDialog::marginHint() );
    grid1->setSpacing( KDialog::spacingHint() );

    grid1->addWidget(findCreated, 0, 0, 1, 3 );
    grid1->addItem( new QSpacerItem(KDialog::spacingHint(), 0), 0, 0 );

    grid1->addWidget(rb[0], 1, 1 );
    grid1->addWidget(fromDate, 1, 2 );
    grid1->addWidget(andL, 1, 3, Qt::AlignHCenter );
    grid1->addWidget(toDate, 1, 4 );

    grid1->addWidget(rb[1], 2, 1 );
    grid1->addWidget(timeBox, 2, 2, 1, 2);
    grid1->addWidget(betweenType, 2, 4 );

    grid1->addWidget(sizeL,3,0,1,2);
    grid1->addWidget(sizeBox,3,2);
    grid1->addWidget(sizeEdit,3,3);
    grid1->addWidget(sizeUnitBox,3,4);

    grid1->addWidget(usernameLabel,4,0,1,2);
    grid1->addWidget(m_usernameBox,4,2);
    grid1->addWidget(groupLabel,4,3);
    grid1->addWidget(m_groupBox,4,4);

    for (int c=1; c<=4; c++)
       grid1->setColumnStretch(c,1);

    grid1->setRowStretch(6,1);

    // Connect
    connect(findCreated, &QCheckBox::toggled, this, &KfindTabWidget::fixLayout);
    connect(bg, static_cast<void (QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked), this, &KfindTabWidget::fixLayout);
    connect(sizeBox, static_cast<void (KComboBox::*)(int)>(&KComboBox::activated), this, &KfindTabWidget::slotSizeBoxChanged);
    connect(timeBox, static_cast<void (KIntSpinBox::*)(int)>(&KIntSpinBox::valueChanged), this, &KfindTabWidget::slotUpdateDateLabelsForNumber);
    connect(betweenType, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &KfindTabWidget::slotUpdateDateLabelsForType);
    connect(sizeEdit, static_cast<void (KIntSpinBox::*)(int)>(&KIntSpinBox::valueChanged), this, &KfindTabWidget::slotUpdateByteComboBox);


    // ************ Page Three

    pages[2] = new QWidget;
    pages[2]->setObjectName( QLatin1String( "page3" ) );

    typeBox =new KComboBox( pages[2] );
    typeBox->setObjectName( QLatin1String( "typeBox" ) );
    typeBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);  // allow smaller than widest entry
    QLabel * typeL   =new QLabel( i18nc("label for the file type combobox","File &type:"), pages[2] );
    typeL->setBuddy( typeBox );
    textEdit=new KLineEdit(pages[2]);
    textEdit->setClearButtonShown(true);
    textEdit->setObjectName( QLatin1String( "textEdit" ) );
    QLabel * textL   =new QLabel(i18n("C&ontaining text:"), pages[2]);
    textL->setBuddy( textEdit );

    connect(textEdit, &KLineEdit::returnPressed, this, &KfindTabWidget::startSearch);

    const QString containingtext
      = i18n("<qt>If specified, only files that contain this text"
	      " are found. Note that not all file types from the list"
		  " above are supported. Please refer to the documentation"
		  " for a list of supported file types."
	      "</qt>");
    textEdit->setToolTip(containingtext);
    textL->setWhatsThis(containingtext);

    caseContextCb  =new QCheckBox(i18n("Case s&ensitive"), pages[2]);
    binaryContextCb  =new QCheckBox(i18n("Include &binary files"), pages[2]);
    regexpContentCb  =new QCheckBox(i18n("Regular e&xpression"), pages[2]);

    const QString binaryTooltip
      = i18n("<qt>This lets you search in any type of file, "
       "even those that usually do not contain text (for example "
	   "program files and images).</qt>");
    binaryContextCb->setToolTip(binaryTooltip);

    QPushButton* editRegExp = 0;
    if ( !KServiceTypeTrader::self()->query(QStringLiteral("KRegExpEditor/KRegExpEditor")).isEmpty() ) {
        // The editor is available, so lets use it.
        editRegExp = new QPushButton(i18n("&Edit..."), pages[2]);
        editRegExp->setObjectName( QLatin1String( "editRegExp" ) );
    }

    metainfokeyEdit=new KLineEdit(pages[2]);
    metainfoEdit=new KLineEdit(pages[2]);
    QLabel * textMetaInfo = new QLabel(i18nc("as in search for", "fo&r:"), pages[2]);
    textMetaInfo->setBuddy( metainfoEdit );
    QLabel * textMetaKey = new QLabel(i18n("Search &metainfo sections:"), pages[2]);
    textMetaKey->setBuddy( metainfokeyEdit );

    // Setup
    typeBox->addItem(i18n("All Files & Folders"));
    typeBox->addItem(i18n("Files"));
    typeBox->addItem(i18n("Folders"));
    typeBox->addItem(i18n("Symbolic Links"));
    typeBox->addItem(i18n("Special Files (Sockets, Device Files, ...)"));
    typeBox->addItem(i18n("Executable Files"));
    typeBox->addItem(i18n("SUID Executable Files"));
    typeBox->addItem(i18n("All Images"));
    typeBox->addItem(i18n("All Video"));
    typeBox->addItem(i18n("All Sounds"));

    initMimeTypes();
    initSpecialMimeTypes();

    for ( KMimeType::List::ConstIterator it = m_types.constBegin();
          it != m_types.constEnd(); ++it )
    {
      KMimeType::Ptr typ = *it;
// TODO: needs to move to thread (increases startup time to bizzare amount)
//       and replaced with a better concept 16x16 icons don't cut the cheese
//       typeBox->addItem(KIconLoader::global()->loadMimeTypeIcon( typ->iconName(), KIconLoader::Small ), typ->comment());
      typeBox->addItem(typ->comment());
    }

    if ( editRegExp ) {
      // The editor was available, so lets use it.
      connect(regexpContentCb, &QCheckBox::toggled, editRegExp, &QPushButton::setEnabled);
      editRegExp->setEnabled(false);
      connect(editRegExp, &QPushButton::clicked, this, &KfindTabWidget::slotEditRegExp);
    }
    else
        regexpContentCb->hide();

    // Layout
    tmp = sizeEdit->fontMetrics().width(QLatin1String(" 00000 "));
    sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height());

    QGridLayout *grid2 = new QGridLayout( pages[2] );
    grid2->setMargin( KDialog::marginHint() );
    grid2->setSpacing( KDialog::spacingHint() );
    grid2->addWidget( typeL, 0, 0 );
    grid2->addWidget( textL, 1, 0 );
    grid2->addWidget( typeBox, 0, 1, 1, 3 );
    grid2->addWidget( textEdit, 1, 1, 1, 3 );
    grid2->addWidget( regexpContentCb, 2, 2);
    grid2->addWidget( caseContextCb, 2, 1 );
    grid2->addWidget( binaryContextCb, 3, 1);

    grid2->addWidget( textMetaKey, 4, 0 );
    grid2->addWidget( metainfokeyEdit, 4, 1 );
    grid2->addWidget( textMetaInfo, 4, 2, Qt::AlignHCenter  );
    grid2->addWidget( metainfoEdit, 4, 3 );

    metainfokeyEdit->setText(QLatin1String("*"));

    if ( editRegExp ) {
      // The editor was available, so lets use it.
      grid2->addWidget( editRegExp, 2, 3 );
    }

    addTab( pages[0], i18n("Name/&Location") );
    addTab( pages[2], i18nc("tab name: search by contents","C&ontents") );
    addTab( pages[1], i18n("&Properties") );


    // Setup
    const QString whatsmetainfo
      = i18n("<qt>Search within files' specific comments/metainfo<br />"
	     "These are some examples:<br />"
	     "<ul>"
	     "<li><b>Audio files (mp3...)</b> Search in id3 tag for a title, an album</li>"
	     "<li><b>Images (png...)</b> Search images with a special resolution, comment...</li>"
	     "</ul>"
	     "</qt>");
    const QString whatsmetainfokey
      = i18n("<qt>If specified, search only in this field<br />"
	     "<ul>"
	     "<li><b>Audio files (mp3...)</b> This can be Title, Album...</li>"
	     "<li><b>Images (png...)</b> Search only in Resolution, Bitdepth...</li>"
	     "</ul>"
	     "</qt>");
    textMetaInfo->setWhatsThis(whatsmetainfo);
    metainfoEdit->setToolTip(whatsmetainfo);
    textMetaKey->setWhatsThis(whatsmetainfokey);
    metainfokeyEdit->setToolTip(whatsmetainfokey);


    fixLayout();
    loadHistory();
}
Ejemplo n.º 23
0
bool readSubreddits(const Options& options)
{
	for (int i = 0; i < (int)options.subreddits.size(); i++)
	{
		if (gTotal >= options.maxToOpen)
			break;

		// open subreddit
		if (options.openSubreddit)
			openUrl("http://www.reddit.com/r/" + options.subreddits[i]);

		vector<HistoryItem> history;
		loadHistory(options.subreddits[i], history);

		if (options.clearHistory)
			history.clear();

		// continue if we don't actual need to fetch the json
		if (options.openLink || options.openPermalink)
		{
			// fetch the url from the server
			string server = string("www.reddit.com");
			string path   = string("/r/") + options.subreddits[i] + string("/.json?limit=") + toStr(options.numToOpen);

			string page = fetchUrl(server, path);

			if (page.size() > 0)
			{
				// convert to json
				block_allocator allocator(1 << 10);
				json_value* root = toJson(page, allocator);
				if (root)
				{
					// find the data we want. this is gross.
					for (json_value* it = root->first_child; it; it = it->next_sibling)
					{
						if (!strcmp(it->name, "data") && it->type == JSON_OBJECT)
						{
							json_value* data = it;
							for (json_value* it = data->first_child; it; it = it->next_sibling)
							{
								if (!strcmp(it->name, "children") && it->type == JSON_ARRAY)
								{
									json_value* child = it;
									for (json_value* it = child->first_child; it; it = it->next_sibling)
									{
										json_value* rec = it;
										for (json_value* it = rec->first_child; it; it = it->next_sibling)
										{
											if (!strcmp(it->name, "data"))
												handleStory(options, history, it);
											if (gTotal >= options.maxToOpen)
												goto out;
										}						
									}
								}
							}
						}
					}
				}
			}
		}
out:
		if (history.size() || options.clearHistory)
			saveHistory(options.subreddits[i], history);
	}

	return true;
}
Ejemplo n.º 24
0
WebHistory::WebHistory(QObject * parent)
		: QWebHistoryInterface(parent)
{
	loadHistory();
}
Ejemplo n.º 25
0
// Update history when triggered by a call back function on the user
// interface.
void HistoryForm::update()
{
	// There is no need to update the history when the window is
	// hidden.
    if (isVisible()) loadHistory();
}