Example #1
0
PhoneBook::PhoneBook(QWidget *parent)
        : QMainWindow(parent)
{
    QWidget *centralWidget = new QWidget(this);
   
    m_editorPage = new ContactEditor(centralWidget);
    connect(m_editorPage, SIGNAL(showListPage()), this, SLOT(activateList()));

    m_filterPage = new FilterPage(centralWidget);
    connect(m_filterPage, SIGNAL(showListPage(QContactFilter)), this, SLOT(activateList(QContactFilter)));

    m_listPage = new ContactListPage(this, centralWidget);
    connect(m_listPage, SIGNAL(showEditorPage(QContactLocalId)), this, SLOT(activateEditor(QContactLocalId)));
    connect(m_listPage, SIGNAL(showFilterPage(QContactFilter)), this, SLOT(activateFind()));
    connect(m_listPage, SIGNAL(managerChanged(QContactManager*)), this, SLOT(managerChanged(QContactManager*)));
    connect(m_listPage, SIGNAL(clearFilter()), m_filterPage, SLOT(clearFilter()));

    m_stackedWidget = new QStackedWidget(centralWidget);
    m_stackedWidget->addWidget(m_listPage);
    m_stackedWidget->addWidget(m_editorPage);
    m_stackedWidget->addWidget(m_filterPage);
    m_stackedWidget->setCurrentIndex(0);

    QVBoxLayout *centralLayout = new QVBoxLayout;
    centralLayout->addWidget(m_stackedWidget);
    centralWidget->setLayout(centralLayout);
    
    setCentralWidget(centralWidget);
}
Example #2
0
void MainWindow::loadLanguage(const QString& rLanguage)
{
    if(m_currLang != rLanguage)
    {
        m_currLang = rLanguage;
        QLocale locale = QLocale(m_currLang);
        GlobalSettings::locale = m_currLang;

        QLocale::setDefault(locale);

        QString languageName = QLocale::languageToString(locale.language());

        bool ok = switchTranslator(m_translatorQt, m_langPath + QString("/qt_%1.qm").arg(m_currLang));
             ok = switchTranslator(m_translator, m_langPath + QString("/editor_%1.qm").arg(m_currLang));

        WriteToLog(QtDebugMsg, QString("Translation-> try to retranslate"));

        if(ok)
        {
            ui->retranslateUi(this);
            WriteToLog(QtDebugMsg, QString("Translation-> done"));
        }
        else
            WriteToLog(QtDebugMsg, QString("Translation-> not changed (not okay)"));

        //Sync dynamic menus
        SyncRecentFiles();
        updateWindowMenu();
        langListSync();

        clearFilter();

        ui->statusBar->showMessage(tr("Current Language changed to %1").arg(languageName), 2000);
    }
}
void MessageFilterDialog::existingFilterSelectionChanged(QListBoxItem * item)
{
  if (item)
  {
    // get the current filter number from the listbox item
    m_currentFilterNum = ((MessageFilterListBoxText*)item)->data();
    
    // get the specified filter
    m_currentFilter = m_filters->filter(m_currentFilterNum);

    // set the GroupBox's label
    m_filterGroup->setTitle(m_currentFilter->name() + " &Filter");

    // setup all the filter values
    m_name->setText(m_currentFilter->name());
    m_pattern->setText(m_currentFilter->regexp().pattern());

    // select all the message types
    uint64_t messageTypes = m_currentFilter->types();
    uint32_t messageType;
    for (QListBoxItem* currentLBT = m_messageTypes->firstItem();
	 currentLBT;
	 currentLBT = currentLBT->next())
    {
      messageType = ((MessageFilterListBoxText*)currentLBT)->data();
      m_messageTypes->setSelected(currentLBT, ((uint64_t(1) << messageType) & messageTypes) != 0);
    }
  }
  else // no item selected, clear all filter setup
    clearFilter();

  // check the current state
  checkState();
}
Example #4
0
//Reload opened file data
void MainWindow::on_actionReload_triggered()
{
    LevelData FileData;
    QString filePath;
    QRect wnGeom;

    if (activeChildWindow()==1)
    {
        filePath = activeLvlEditWin()->curFile;

        QFile fileIn(filePath);

        if (!fileIn.open(QIODevice::ReadOnly)) {
        QMessageBox::critical(this, tr("File open error"),
        tr("Can't open the file."), QMessageBox::Ok);
            return;
        }

        FileData = FileFormats::ReadLevelFile(fileIn); //function in file_formats.cpp
        if( !FileData.ReadFileValid ){
            statusBar()->showMessage(tr("Reloading error"), 2000);
            return;}

        FileData.filename = QFileInfo(filePath).baseName();
        FileData.path = QFileInfo(filePath).absoluteDir().absolutePath();
        FileData.playmusic = GlobalSettings::autoPlayMusic;
        activeLvlEditWin()->LvlData.modified = false;
        activeLvlEditWin()->close();
        wnGeom = ui->centralWidget->activeSubWindow()->geometry();
        ui->centralWidget->activeSubWindow()->close();

        leveledit *child = createLvlChild();
        if ((bool) (child->loadFile(filePath, FileData, configs, GlobalSettings::LvlOpts))) {
            statusBar()->showMessage(tr("Level file reloaded"), 2000);
            child->show();
            ui->centralWidget->activeSubWindow()->setGeometry(wnGeom);
            updateMenus(true);
            SetCurrentLevelSection(0);

            if(GlobalSettings::autoPlayMusic) ui->actionPlayMusic->setChecked(true);
            LvlMusPlay::musicForceReset=true; //reset musics
            on_actionPlayMusic_triggered(ui->actionPlayMusic->isChecked());

        } else {
                WriteToLog(QtDebugMsg, ">>File loading aborted");
            child->show();
                WriteToLog(QtDebugMsg, ">>Window showed");
            if(activeChildWindow()==1) activeLvlEditWin()->LvlData.modified = false;
                WriteToLog(QtDebugMsg, ">>Option set");
            ui->centralWidget->activeSubWindow()->close();
                WriteToLog(QtDebugMsg, ">>Windows closed");
        }
    }

    clearFilter();
}
Example #5
0
void Filtering::on_textLE_textChanged (const QString& s)
{
	kdebugf();
	
	clearFilter ();
	
	if (! s.isEmpty ())
		filterWith (s);
	
	kdebugf2();
}
void MessageFilterDialog::newFilter()
{
  // clear any selection
  m_existingFilters->clearSelection();

  // clear the filter display
  clearFilter();

  // check the current state and set UI up accordingly
  checkState();
}
Example #7
0
Debug::Debug( const char *filterString, const char *verboseString,
              Time filterStartTime, const char *filename )
{
  m_verbosityLevel = No_Verb;
  clearFilter();
  debug_cout_ptr = &cout;
  
  m_starting_cycle = filterStartTime;
  setFilterString( filterString );
  setVerbosityString( verboseString );
  setDebugOutputFile( filename );
}
void MessageFilterDialog::deleteFilter()
{
  // remove the current filter (if any are selected)
  if (m_currentFilter)
    m_filters->remFilter(*m_currentFilter);

  // clear any selection
  m_existingFilters->clearSelection();

  // clear the filter display
  clearFilter();

  // check the current state and set UI up accordingly
  checkState();
}
Example #9
0
bool Debug::setFilterString(const char *filter_str)
{
  if (checkFilterString(filter_str)) {
    return true; // error
  }

  if (string(filter_str) == "all" ) {
    allFilter();
  } else if (string(filter_str) == "none") {
    clearFilter();
  } else {
    // scan string adding to bit mask for each component which is present
    for (unsigned int i = 0; i < strlen(filter_str); i++) {
      bool error = addFilter( filter_str[i] );
      if (error) {
        return true; // error
      }
    }
  }
  return false; // no error
}
Example #10
0
void MainWindow::on_actionLoad_configs_triggered()
{

    QProgressDialog progress("Please wait...", tr("Abort"), 0,100, this);
    progress.setWindowTitle(tr("Reloading configurations"));
    //progress.setWindowModality(Qt::WindowModal);
    progress.setModal(true);
    progress.setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
    progress.setFixedSize(progress.size());
    progress.setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, progress.size(), qApp->desktop()->availableGeometry()));
    progress.setCancelButton(0);
    progress.setMinimumDuration(0);
    progress.setAutoClose(false);
    //progress.show();

    if(!progress.wasCanceled()) progress.setValue(1);

    //Reload configs
    qApp->processEvents();
    configs.loadconfigs(&progress);

    if(!progress.wasCanceled())  progress.setValue(100);

    setLvlItemBoxes(false); //Apply item boxes from reloaded configs
    setWldItemBoxes(false);

    setLevelSectionData();
    setSoundList();
    clearFilter();

    //Set tools from loaded configs
    //setLevelSectionData();

    if(!progress.wasCanceled())
        progress.close();

    QMessageBox::information(this, tr("Reloading configuration"),
    tr("Configuration succesfully reloaded!"),
    QMessageBox::Ok);
}
Example #11
0
				AccountActsMgr_->GetStatusText (static_cast<QAction*> (sender ()), state));
		for (IAccount *acc : Core::Instance ().GetAccounts ())
			if (acc->IsShownInRoster ())
				acc->ChangeState (status);
	}

	void MainWidget::handleEntryActivationType ()
	{
		disconnect (Ui_.CLTree_,
				0,
				this,
				SLOT (treeActivated (const QModelIndex&)));
		disconnect (Ui_.CLTree_,
				0,
				this,
				SLOT (clearFilter ()));

		const char *signal = 0;
		const QString& actType = XmlSettingsManager::Instance ()
				.property ("EntryActivationType").toString ();

		if (actType == "click")
			signal = SIGNAL (clicked (const QModelIndex&));
		else if (actType == "dclick")
			signal = SIGNAL (doubleClicked (const QModelIndex&));
		else
			signal = SIGNAL (activated (const QModelIndex&));

		connect (Ui_.CLTree_,
				signal,
				this,
Example #12
0
//
// Constructor
//
HistogramWindow::HistogramWindow(Context *context, bool rangemode) : GcChartWindow(context), context(context), stale(true), source(NULL), active(false), bactive(false), rangemode(rangemode), useCustom(false), useToToday(false), precision(99)
{
    QWidget *c = new QWidget;
    c->setContentsMargins(0,0,0,0);
    QFormLayout *cl = new QFormLayout(c);
    cl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
    cl->setSpacing(5);
    setControls(c);

    //
    // reveal controls widget
    //

    // reveal controls
    rWidth = new QLabel(tr("Bin Width"));
    rBinEdit = new QLineEdit();
    rBinEdit->setFixedWidth(40);
    rBinSlider = new QSlider(Qt::Horizontal);
    rBinSlider->setTickPosition(QSlider::TicksBelow);
    rBinSlider->setTickInterval(10);
    rBinSlider->setMinimum(1);
    rBinSlider->setMaximum(100);
    rShade = new QCheckBox(tr("Shade zones"));
    rZones = new QCheckBox(tr("Show in zones"));

    // layout reveal controls
    QHBoxLayout *r = new QHBoxLayout;
    r->setContentsMargins(0,0,0,0);
    r->addStretch();
    r->addWidget(rWidth);
    r->addWidget(rBinEdit);
    r->addWidget(rBinSlider);
    QVBoxLayout *v = new QVBoxLayout;
    v->addWidget(rShade);
    v->addWidget(rZones);
    r->addSpacing(20);
    r->addLayout(v);
    r->addStretch();
    setRevealLayout(r);

    // plot
    QVBoxLayout *vlayout = new QVBoxLayout;
    vlayout->setSpacing(10);
    powerHist = new PowerHist(context);
    vlayout->addWidget(powerHist);

    setChartLayout(vlayout);

#ifdef GC_HAVE_LUCENE
    // search filter box
    isfiltered = false;
    searchBox = new SearchFilterBox(this, context);
    connect(searchBox, SIGNAL(searchClear()), this, SLOT(clearFilter()));
    connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(setFilter(QStringList)));
    if (!rangemode) searchBox->hide();
    else {
        cl->addRow(new QLabel(tr("Filter")), searchBox);
        cl->addWidget(new QLabel(""));
    }
#endif

    // date selection
    dateSetting = new DateSettingsEdit(this);

    if (rangemode) {

        cl->addRow(new QLabel(tr("Date Range")), dateSetting);
        cl->addWidget(new QLabel("")); // spacing

        // default to data series!
        data = new QRadioButton(tr("Ride Data Samples"));
        metric = new QRadioButton(tr("Ride Metrics"));
        data->setChecked(true);
        metric->setChecked(false);
        QHBoxLayout *radios = new QHBoxLayout;
        radios->addWidget(data);
        radios->addWidget(metric);
        cl->addRow(new QLabel(tr("Plot")), radios);

        connect(data, SIGNAL(toggled(bool)), this, SLOT(dataToggled(bool)));
        connect(metric, SIGNAL(toggled(bool)), this, SLOT(metricToggled(bool)));
    }

    // data series
    seriesCombo = new QComboBox();
    addSeries();
    if (rangemode) comboLabel = new QLabel("");
    else comboLabel = new QLabel(tr("Data Series"));
    cl->addRow(comboLabel, seriesCombo);

    if (rangemode) {

        // TOTAL METRIC
        totalMetricTree = new QTreeWidget;
#ifdef Q_OS_MAC
        totalMetricTree->setAttribute(Qt::WA_MacShowFocusRect, 0);
#endif
        totalMetricTree->setColumnCount(2);
        totalMetricTree->setColumnHidden(1, true);
        totalMetricTree->setSelectionMode(QAbstractItemView::SingleSelection);
        totalMetricTree->header()->hide();
        //totalMetricTree->setFrameStyle(QFrame::NoFrame);
        //totalMetricTree->setAlternatingRowColors (true);
        totalMetricTree->setIndentation(5);
        totalMetricTree->setContextMenuPolicy(Qt::CustomContextMenu);

        // ALL METRIC
        distMetricTree = new QTreeWidget;
#ifdef Q_OS_MAC
        distMetricTree->setAttribute(Qt::WA_MacShowFocusRect, 0);
#endif
        distMetricTree->setColumnCount(2);
        distMetricTree->setColumnHidden(1, true);
        distMetricTree->setSelectionMode(QAbstractItemView::SingleSelection);
        distMetricTree->header()->hide();
        //distMetricTree->setFrameStyle(QFrame::NoFrame);
        distMetricTree->setIndentation(5);
        distMetricTree->setContextMenuPolicy(Qt::CustomContextMenu);

        // add them all
        const RideMetricFactory &factory = RideMetricFactory::instance();
        for (int i = 0; i < factory.metricCount(); ++i) {

            const RideMetric *m = factory.rideMetric(factory.metricName(i));

            QTextEdit processHTML(m->name()); // process html encoding of(TM)
            QString processed = processHTML.toPlainText();

            QTreeWidgetItem *add;
            add = new QTreeWidgetItem(distMetricTree->invisibleRootItem());
            add->setText(0, processed);
            add->setText(1, m->symbol());

            // we only want totalising metrics
            if (m->type() != RideMetric::Total) continue;

            add = new QTreeWidgetItem(totalMetricTree->invisibleRootItem());
            add->setText(0, processed);
            add->setText(1, m->symbol());
        }

        QHBoxLayout *labels = new QHBoxLayout;

        metricLabel1 = new QLabel(tr("Total (x-axis)"));
        labels->addWidget(metricLabel1);
        metricLabel1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);

        metricLabel2 = new QLabel(tr("Distribution (y-axis)"));
        metricLabel2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
        labels->addWidget(metricLabel2);

        cl->addRow((blankLabel1=new QLabel("")), labels);
        QHBoxLayout *trees = new QHBoxLayout;
        trees->addWidget(totalMetricTree);
        trees->addWidget(distMetricTree);
        cl->addRow((blankLabel2 = new QLabel("")), trees);

        colorButton = new ColorButton(this, "Color", QColor(Qt::blue));
        colorLabel = new QLabel(tr("Color"));
        connect(colorButton, SIGNAL(colorChosen(QColor)), this, SLOT(updateChart()));
        cl->addRow(colorLabel, colorButton);

        // by default select number of rides by duration
        // which are the metrics workout_time and ride_count
        selectTotal("ride_count");
        selectMetric("workout_time");
    }

    showSumY = new QComboBox();
    showSumY->addItem(tr("Absolute Time"));
    showSumY->addItem(tr("Percentage Time"));

    showLabel = new QLabel(tr("Show"));
    cl->addRow(showLabel, showSumY);

    showLnY = new QCheckBox;
    showLnY->setText(tr("Log Y"));
    cl->addRow(blankLabel3 = new QLabel(""), showLnY);

    showZeroes = new QCheckBox;
    showZeroes->setText(tr("With zeros"));
    cl->addRow(blankLabel4 = new QLabel(""), showZeroes);

    shadeZones = new QCheckBox;
    shadeZones->setText(tr("Shade zones"));
    cl->addRow(blankLabel5 = new QLabel(""), shadeZones);

    showInZones = new QCheckBox;
    showInZones->setText(tr("Show in zones"));
    cl->addRow(blankLabel6 = new QLabel(""), showInZones);

    // bin width
    QHBoxLayout *binWidthLayout = new QHBoxLayout;
    QLabel *binWidthLabel = new QLabel(tr("Bin width"), this);
    binWidthLineEdit = new QLineEdit(this);
    binWidthLineEdit->setFixedWidth(40);

    binWidthLayout->addWidget(binWidthLineEdit);
    binWidthSlider = new QSlider(Qt::Horizontal);
    binWidthSlider->setTickPosition(QSlider::TicksBelow);
    binWidthSlider->setTickInterval(1);
    binWidthSlider->setMinimum(1);
    binWidthSlider->setMaximum(100);
    binWidthLayout->addWidget(binWidthSlider);
    cl->addRow(binWidthLabel, binWidthLayout);

    // sort out default values
    setBinEditors();
    showLnY->setChecked(powerHist->islnY());
    showZeroes->setChecked(powerHist->withZeros());
    shadeZones->setChecked(powerHist->shade);
    binWidthSlider->setValue(powerHist->binWidth());
    rBinSlider->setValue(powerHist->binWidth());
    rShade->setChecked(powerHist->shade);

    // fixup series selected by default
    seriesChanged();

    // hide/show according to default mode
    switchMode(); // does nothing if not in rangemode

    // set the defaults etc
    updateChart();

    // the bin slider/input update each other
    // only the input box triggers an update to the chart
    connect(binWidthSlider, SIGNAL(valueChanged(int)), this, SLOT(setBinWidthFromSlider()));
    connect(binWidthLineEdit, SIGNAL(editingFinished()), this, SLOT(setBinWidthFromLineEdit()));
    connect(rBinSlider, SIGNAL(valueChanged(int)), this, SLOT(setrBinWidthFromSlider()));
    connect(rBinEdit, SIGNAL(editingFinished()), this, SLOT(setrBinWidthFromLineEdit()));
    connect(rZones, SIGNAL(stateChanged(int)), this, SLOT(setZoned(int)));
    connect(rShade, SIGNAL(stateChanged(int)), this, SLOT(setShade(int)));

    // when season changes we need to retrieve data from the cache then update the chart
    if (rangemode) {
        connect(this, SIGNAL(dateRangeChanged(DateRange)), this, SLOT(dateRangeChanged(DateRange)));
        connect(dateSetting, SIGNAL(useCustomRange(DateRange)), this, SLOT(useCustomRange(DateRange)));
        connect(dateSetting, SIGNAL(useThruToday()), this, SLOT(useThruToday()));
        connect(dateSetting, SIGNAL(useStandardRange()), this, SLOT(useStandardRange()));
        connect(distMetricTree, SIGNAL(itemSelectionChanged()), this, SLOT(treeSelectionChanged()));
        connect(totalMetricTree, SIGNAL(itemSelectionChanged()), this, SLOT(treeSelectionChanged()));

        lagger = new QTimer;
        lagger->setSingleShot(true);
        connect(lagger, SIGNAL(timeout()), this, SLOT(treeSelectionTimeout()));

    } else {
        dateSetting->hide();
        connect(this, SIGNAL(rideItemChanged(RideItem*)), this, SLOT(rideSelected()));
        connect(context, SIGNAL(intervalSelected()), this, SLOT(intervalSelected()));
    }

    // if any of the controls change we pass the chart everything
    connect(showLnY, SIGNAL(stateChanged(int)), this, SLOT(updateChart()));
    connect(showZeroes, SIGNAL(stateChanged(int)), this, SLOT(updateChart()));
    connect(seriesCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(seriesChanged()));
    connect(showInZones, SIGNAL(stateChanged(int)), this, SLOT(setZoned(int)));
    connect(showInZones, SIGNAL(stateChanged(int)), this, SLOT(updateChart()));
    connect(shadeZones, SIGNAL(stateChanged(int)), this, SLOT(setShade(int)));
    connect(shadeZones, SIGNAL(stateChanged(int)), this, SLOT(updateChart()));
    connect(showSumY, SIGNAL(currentIndexChanged(int)), this, SLOT(updateChart()));

    connect(context->athlete, SIGNAL(zonesChanged()), this, SLOT(zonesChanged()));
    connect(context, SIGNAL(configChanged()), powerHist, SLOT(configChanged()));

    connect(context, SIGNAL(rideAdded(RideItem*)), this, SLOT(rideAddorRemove(RideItem*)));
    connect(context, SIGNAL(rideDeleted(RideItem*)), this, SLOT(rideAddorRemove(RideItem*)));
    connect(context, SIGNAL(filterChanged()), this, SLOT(forceReplot()));
    connect(context, SIGNAL(homeFilterChanged()), this, SLOT(forceReplot()));
}
Example #13
0
/*!
    Resets current filter, applying new filter on Category \a filterType containing string \a text

    eg. setFilter(QMediaList::MimeType,"audio");

    Returns false on error.
*/
bool QMediaList::setFilter(Roles filterType, const QString& text)
{
    clearFilter();
    return addFilter(filterType, text);
}
Example #14
0
QMediaList::QMediaList()
    : QAbstractListModel()
{
    d = new QMediaListPrivate(this);
    clearFilter();
}
TransactionFilterWidget::TransactionFilterWidget(bool extra_parameters, int transaction_type, Budget *budg, QWidget *parent) : QWidget(parent), transtype(transaction_type), budget(budg), b_extra(extra_parameters) {
	payeeEdit = NULL;
	int rows = 5;
	if(b_extra && (transtype == TRANSACTION_TYPE_EXPENSE || transtype == TRANSACTION_TYPE_INCOME)) rows = 6;
	QGridLayout *filterLayout = new QGridLayout(this);
	filterLayout->setContentsMargins(0, 0, 0, 0);
	dateFromButton = new QCheckBox(i18n("From:"), this);
	dateFromButton->setChecked(false);
	filterLayout->addWidget(dateFromButton, 0, 0);
	dateFromEdit = new KDateEdit(this);
	dateFromEdit->setSizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow);
	dateFromEdit->setEnabled(false);
	filterLayout->addWidget(dateFromEdit, 0, 1);
	filterLayout->addWidget(new QLabel(i18n("To:"), this), 0, 2);
	dateToEdit = new KDateEdit(this);
	dateToEdit->setSizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow);
	filterLayout->addWidget(dateToEdit, 0, 3);
	QDate curdate = QDate::currentDate();
	from_date.setYMD(curdate.year(), curdate.month(), 1);
	dateFromEdit->setDate(from_date);
	to_date = curdate;
	dateToEdit->setDate(to_date);
	if(transtype == TRANSACTION_TYPE_TRANSFER) {
		filterLayout->addWidget(new QLabel(i18n("From:"), this), 2, 0);
		fromCombo = new KComboBox(this);
		fromCombo->setEditable(false);
		filterLayout->addWidget(fromCombo, 2, 1);
		filterLayout->addWidget(new QLabel(i18n("To:"), this), 2, 2);
		toCombo = new KComboBox(this);
		toCombo->setEditable(false);
		filterLayout->addWidget(toCombo, 2, 3);
		minButton = new QCheckBox(i18n("Min amount:"), this);
		maxButton = new QCheckBox(i18n("Max amount:"), this);
	} else if(transtype == TRANSACTION_TYPE_INCOME) {
		filterLayout->addWidget(new QLabel(i18n("Category:"), this), 2, 0);
		fromCombo = new KComboBox(this);
		fromCombo->setEditable(false);
		filterLayout->addWidget(fromCombo, 2, 1);
		filterLayout->addWidget(new QLabel(i18n("To account:"), this), 2, 2);
		toCombo = new KComboBox(this);
		toCombo->setEditable(false);
		filterLayout->addWidget(toCombo, 2, 3);
		minButton = new QCheckBox(i18n("Min income:"), this);
		maxButton = new QCheckBox(i18n("Max income:"), this);
	} else {
		filterLayout->addWidget(new QLabel(i18n("Category:"), this), 2, 0);
		toCombo = new KComboBox(this);
		toCombo->setEditable(false);
		filterLayout->addWidget(toCombo, 2, 1);
		filterLayout->addWidget(new QLabel(i18n("From account:"), this), 2, 2);
		fromCombo = new KComboBox(this);
		fromCombo->setEditable(false);
		filterLayout->addWidget(fromCombo, 2, 3);
		minButton = new QCheckBox(i18n("Min cost:"), this);
		maxButton = new QCheckBox(i18n("Max cost:"), this);
	}
	filterLayout->addWidget(minButton, 1, 0);
	minEdit = new EqonomizeValueEdit(false, this);
	minEdit->setEnabled(false);
	filterLayout->addWidget(minEdit, 1, 1);
	filterLayout->addWidget(maxButton, 1, 2);
	maxEdit = new EqonomizeValueEdit(false, this);
	maxEdit->setEnabled(false);
	QSizePolicy sp = maxEdit->sizePolicy();
	sp.setHorizontalPolicy(QSizePolicy::Expanding);
	maxEdit->setSizePolicy(sp);
	filterLayout->addWidget(maxEdit, 1, 3);
	filterLayout->addWidget(new QLabel(i18n("Description:"), this), 3, 0);
	descriptionEdit = new KLineEdit(this);
	descriptionEdit->setCompletionMode(KGlobalSettings::CompletionPopup);
	filterLayout->addWidget(descriptionEdit, 3, 1);
	if(b_extra && (transtype == TRANSACTION_TYPE_EXPENSE || transtype == TRANSACTION_TYPE_INCOME)) {
		if(transtype == TRANSACTION_TYPE_INCOME) filterLayout->addWidget(new QLabel(i18n("Payer:"), this), 3, 2);
		else filterLayout->addWidget(new QLabel(i18n("Payee:"), this), 3, 2);
		payeeEdit = new KLineEdit(this);
		payeeEdit->setCompletionMode(KGlobalSettings::CompletionPopup);
		filterLayout->addWidget(payeeEdit, 3, 3);
	}
	QHBoxLayout *filterExcludeLayout = new QHBoxLayout();
	group = new QButtonGroup(this);
	includeButton = new QRadioButton(i18n("Include"), this);
	includeButton->setChecked(true);
	group->addButton(includeButton);
	filterExcludeLayout->addWidget(includeButton);
	excludeButton = new QRadioButton(i18n("Exclude"), this);
	group->addButton(excludeButton);
	filterExcludeLayout->addWidget(excludeButton);
	filterExcludeLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
	clearButton = new KPushButton(KStandardGuiItem::clear(), this);
	clearButton->setEnabled(false);
	filterExcludeLayout->addWidget(clearButton);
	if(payeeEdit) {
		filterLayout->addLayout(filterExcludeLayout, 4, 0, 1, 4);
		filterLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding), 5, 0, 1, 4);
	} else {
		filterLayout->addLayout(filterExcludeLayout, 3, 2, 1, 2);
		filterLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding), 4, 0, 1, 4);
	}

	fromCombo->addItem(i18n("All"));
	toCombo->addItem(i18n("All"));

	descriptionEdit->completionObject()->setIgnoreCase(true);
	if(payeeEdit) payeeEdit->completionObject()->setIgnoreCase(true);
	
	if(payeeEdit) {
		connect(payeeEdit, SIGNAL(textChanged(const QString&)), this, SIGNAL(filter()));
		connect(payeeEdit, SIGNAL(textChanged(const QString&)), this, SLOT(checkEnableClear()));
	}
	connect(clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
	connect(group, SIGNAL(buttonClicked(int)), this, SIGNAL(filter()));
	connect(dateFromButton, SIGNAL(toggled(bool)), dateFromEdit, SLOT(setEnabled(bool)));
	connect(dateFromButton, SIGNAL(toggled(bool)), this, SIGNAL(filter()));
	connect(dateFromButton, SIGNAL(toggled(bool)), this, SLOT(checkEnableClear()));
	connect(dateFromEdit, SIGNAL(dateChanged(const QDate&)), this, SLOT(fromChanged(const QDate&)));
	connect(dateToEdit, SIGNAL(dateChanged(const QDate&)), this, SLOT(toChanged(const QDate&)));
	connect(dateToEdit, SIGNAL(dateChanged(const QDate&)), this, SLOT(checkEnableClear()));
	connect(toCombo, SIGNAL(activated(int)), this, SIGNAL(filter()));
	connect(fromCombo, SIGNAL(activated(int)), this, SIGNAL(filter()));
	connect(toCombo, SIGNAL(activated(int)), this, SLOT(checkEnableClear()));
	connect(fromCombo, SIGNAL(activated(int)), this, SLOT(checkEnableClear()));
	connect(toCombo, SIGNAL(activated(int)), this, SIGNAL(toActivated(int)));
	connect(fromCombo, SIGNAL(activated(int)), this, SIGNAL(fromActivated(int)));
	connect(descriptionEdit, SIGNAL(textChanged(const QString&)), this, SIGNAL(filter()));
	connect(descriptionEdit, SIGNAL(textChanged(const QString&)), this, SLOT(checkEnableClear()));
	connect(minButton, SIGNAL(toggled(bool)), this, SIGNAL(filter()));
	connect(minButton, SIGNAL(toggled(bool)), this, SLOT(checkEnableClear()));
	connect(minButton, SIGNAL(toggled(bool)), minEdit, SLOT(setEnabled(bool)));
	connect(minEdit, SIGNAL(valueChanged(double)), this, SIGNAL(filter()));
	connect(maxButton, SIGNAL(toggled(bool)), this, SIGNAL(filter()));
	connect(maxButton, SIGNAL(toggled(bool)), this, SLOT(checkEnableClear()));
	connect(maxButton, SIGNAL(toggled(bool)), maxEdit, SLOT(setEnabled(bool)));
	connect(maxEdit, SIGNAL(valueChanged(double)), this, SIGNAL(filter()));
	
}
CaptureFilterEdit::CaptureFilterEdit(QWidget *parent, bool plain) :
    SyntaxLineEdit(parent),
    plain_(plain),
    field_name_only_(false),
    enable_save_action_(false),
    save_action_(NULL),
    remove_action_(NULL),
    bookmark_button_(NULL),
    clear_button_(NULL),
    apply_button_(NULL)
{
    setAccessibleName(tr("Capture filter entry"));

    completion_model_ = new QStringListModel(this);
    setCompleter(new QCompleter(completion_model_, this));
    setCompletionTokenChars(libpcap_primitive_chars_);

    setConflict(false);

    if (!plain_) {
        bookmark_button_ = new StockIconToolButton(this, "x-capture-filter-bookmark");
        bookmark_button_->setCursor(Qt::ArrowCursor);
        bookmark_button_->setMenu(new QMenu());
        bookmark_button_->setPopupMode(QToolButton::InstantPopup);
        bookmark_button_->setToolTip(tr("Manage saved bookmarks."));
        bookmark_button_->setIconSize(QSize(14, 14));
        bookmark_button_->setStyleSheet(
                    "QToolButton {"
                    "  border: none;"
                    "  background: transparent;" // Disables platform style on Windows.
                    "  padding: 0 0 0 0;"
                    "}"
                    "QToolButton::menu-indicator { image: none; }"
            );
        connect(bookmark_button_, SIGNAL(clicked()), this, SLOT(bookmarkClicked()));
    }

    if (!plain_) {
        clear_button_ = new StockIconToolButton(this, "x-filter-clear");
        clear_button_->setCursor(Qt::ArrowCursor);
        clear_button_->setToolTip(QString());
        clear_button_->setIconSize(QSize(14, 14));
        clear_button_->setStyleSheet(
                "QToolButton {"
                "  border: none;"
                "  background: transparent;" // Disables platform style on Windows.
                "  padding: 0 0 0 0;"
                "  margin-left: 1px;"
                "}"
                );
        connect(clear_button_, SIGNAL(clicked()), this, SLOT(clearFilter()));
    }

    connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(checkFilter(const QString&)));

#if 0
    // Disable the apply button for now
    if (!plain_) {
        apply_button_ = new StockIconToolButton(this, "x-filter-apply");
        apply_button_->setCursor(Qt::ArrowCursor);
        apply_button_->setEnabled(false);
        apply_button_->setToolTip(tr("Apply this filter string to the display."));
        apply_button_->setIconSize(QSize(24, 14));
        apply_button_->setStyleSheet(
                "QToolButton {"
                "  border: none;"
                "  background: transparent;" // Disables platform style on Windows.
                "  padding: 0 0 0 0;"
                "}"
                );
        connect(apply_button_, SIGNAL(clicked()), this, SLOT(applyCaptureFilter()));
    }
#endif
    connect(this, SIGNAL(returnPressed()), this, SLOT(applyCaptureFilter()));

    int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
    QSize bksz;
    if (bookmark_button_) bksz = bookmark_button_->sizeHint();
    QSize cbsz;
    if (clear_button_) cbsz = clear_button_->sizeHint();
    QSize apsz;
    if (apply_button_) apsz = apply_button_->sizeHint();

    setStyleSheet(QString(
            "CaptureFilterEdit {"
            "  padding-left: %1px;"
            "  margin-left: %2px;"
            "  margin-right: %3px;"
            "}"
            )
            .arg(frameWidth + 1)
            .arg(bksz.width())
            .arg(cbsz.width() + apsz.width() + frameWidth + 1)
            );

    QComboBox *cf_combo = qobject_cast<QComboBox *>(parent);
    if (cf_combo) {
        connect(cf_combo, SIGNAL(activated(QString)), this, SIGNAL(textEdited(QString)));
    }

    QThread *syntax_thread = new QThread;
    syntax_worker_ = new CaptureFilterSyntaxWorker;
    syntax_worker_->moveToThread(syntax_thread);
    connect(wsApp, SIGNAL(appInitialized()), this, SLOT(updateBookmarkMenu()));
    connect(wsApp, SIGNAL(captureFilterListChanged()), this, SLOT(updateBookmarkMenu()));
    connect(syntax_thread, SIGNAL(started()), syntax_worker_, SLOT(start()));
    connect(syntax_thread, SIGNAL(started()), this, SLOT(checkFilter()));
    connect(syntax_worker_, SIGNAL(syntaxResult(QString,int,QString)),
            this, SLOT(setFilterSyntaxState(QString,int,QString)));
    connect(syntax_thread, SIGNAL(finished()), syntax_worker_, SLOT(deleteLater()));
    syntax_thread->start();
}
void MessageFilterDialog::addFilter()
{
  uint32_t type;
  uint64_t types = 0;

  // iterate over the message types
  for (QListBoxItem* currentLBT = m_messageTypes->firstItem();
       currentLBT;
       currentLBT = currentLBT->next())
  {
    // if the item isn't selected, add in its type flag, and enable updates
    if (currentLBT->isSelected())
    {
      // get the message type of the selected item
      type = ((MessageFilterListBoxText*)currentLBT)->data();

      // add its flag to the types 
      types |= (uint64_t(1) << type);
    }
  } 

  // create a message filter object
  MessageFilter newFilter(m_name->text(), types, m_pattern->text());

  // if this isn't a valid filter, don't create it
  if (!newFilter.valid())
    return;

  // add the new filter
  m_currentFilterNum = m_filters->addFilter(newFilter);
  
  // if it is a valid filter, make the new filter the current selection
  if (m_currentFilterNum != 0xFF)
  {
    // retrieve the current item
    m_currentFilter = m_filters->filter(m_currentFilterNum);

    // iterate over the existing filters
    for (QListBoxItem* currentLBT = m_existingFilters->firstItem();
	 currentLBT;
	 currentLBT = currentLBT->next())
    {
      // find the current filter
      if (((MessageFilterListBoxText*)currentLBT)->data() == m_currentFilterNum)
      {
	// make the current filter the selected filter
	m_existingFilters->setSelected(currentLBT, true);
	break;
      }
    }
  }
  else // clear the current filter
  {
    // clear the current filter
    m_currentFilter = 0;
    clearFilter();
  }
  
  // setup the current dialog state
  checkState();
}
Example #18
0
MainWindow::MainWindow(const QDir &home)
{
    /*----------------------------------------------------------------------
     *  Bootstrap
     *--------------------------------------------------------------------*/
    setAttribute(Qt::WA_DeleteOnClose);
    mainwindows.append(this);  // add us to the list of open windows
    context = new Context(this);
    context->athlete = new Athlete(context, home);

    setInstanceName(context->athlete->cyclist);
    setWindowIcon(QIcon(":images/gc.png"));
    setWindowTitle(context->athlete->home.dirName());
    setContentsMargins(0,0,0,0);
    setAcceptDrops(true);
    GCColor *GCColorSet = new GCColor(context); // get/keep colorset
    GCColorSet->colorSet(); // shut up the compiler

    #ifdef Q_OS_MAC
    // get an autorelease pool setup
    static CocoaInitializer cocoaInitializer;
    #endif
    #ifdef GC_HAVE_WFAPI
    WFApi *w = WFApi::getInstance(); // ensure created on main thread
    w->apiVersion();//shutup compiler
    #endif
    Library::initialise(context->athlete->home);
    QNetworkProxyQuery npq(QUrl("http://www.google.com"));
    QList<QNetworkProxy> listOfProxies = QNetworkProxyFactory::systemProxyForQuery(npq);
    if (listOfProxies.count() > 0) {
        QNetworkProxy::setApplicationProxy(listOfProxies.first());
    }

    if (desktop == NULL) desktop = QApplication::desktop();
    static const QIcon hideIcon(":images/toolbar/main/hideside.png");
    static const QIcon rhideIcon(":images/toolbar/main/hiderside.png");
    static const QIcon showIcon(":images/toolbar/main/showside.png");
    static const QIcon rshowIcon(":images/toolbar/main/showrside.png");
    static const QIcon tabIcon(":images/toolbar/main/tab.png");
    static const QIcon tileIcon(":images/toolbar/main/tile.png");
    static const QIcon fullIcon(":images/toolbar/main/togglefull.png");

#if (defined Q_OS_MAC) && (defined GC_HAVE_LION)
    fullScreen = new LionFullScreen(context);
#endif
#ifndef Q_OS_MAC
    fullScreen = new QTFullScreen(context);
#endif

    // if no workout directory is configured, default to the
    // top level GoldenCheetah directory
    if (appsettings->value(NULL, GC_WORKOUTDIR).toString() == "")
        appsettings->setValue(GC_WORKOUTDIR, QFileInfo(context->athlete->home.absolutePath() + "/../").absolutePath());

    /*----------------------------------------------------------------------
     *  GUI setup
     *--------------------------------------------------------------------*/

    // need to restore geometry before setUnifiedToolBar.. on Mac
    appsettings->setValue(GC_SETTINGS_LAST, context->athlete->home.dirName());
    QVariant geom = appsettings->value(this, GC_SETTINGS_MAIN_GEOM);
    if (geom == QVariant()) {

        // first run -- lets set some sensible defaults...
        // lets put it in the middle of screen 1
        QRect size = desktop->availableGeometry();
        struct SizeSettings app = GCColor::defaultSizes(size.height(), size.width());

        // center on the available screen (minus toolbar/sidebar)
        move((size.width()-size.x())/2 - app.width/2,
             (size.height()-size.y())/2 - app.height/2);

        // set to the right default
        resize(app.width, app.height);

        // set all the default font sizes
        appsettings->setValue(GC_FONT_DEFAULT_SIZE, app.defaultFont);
        appsettings->setValue(GC_FONT_TITLES_SIZE, app.titleFont);
        appsettings->setValue(GC_FONT_CHARTMARKERS_SIZE, app.markerFont);
        appsettings->setValue(GC_FONT_CHARTLABELS_SIZE, app.labelFont);
        appsettings->setValue(GC_FONT_CALENDAR_SIZE, app.calendarFont);
        appsettings->setValue(GC_FONT_POPUP_SIZE, app.popupFont);

        // set the default fontsize
        QFont font;
        font.setPointSize(app.defaultFont);
        QApplication::setFont(font);

    } else {

        QRect size = desktop->availableGeometry();

        // ensure saved geometry isn't greater than current screen size
        if ((geom.toRect().height() >= size.height()) || (geom.toRect().width() >= size.width()))
            setGeometry(size.x()+30,size.y()+30,size.width()-60,size.height()-60);
        else
            setGeometry(geom.toRect());
    }


    /*----------------------------------------------------------------------
     *  Mac Toolbar
     *--------------------------------------------------------------------*/
#ifdef Q_OS_MAC 
    setUnifiedTitleAndToolBarOnMac(true);
    head = addToolBar(context->athlete->cyclist);
    head->setContentsMargins(0,0,0,0);

    // widgets
    QWidget *macAnalButtons = new QWidget(this);
    macAnalButtons->setContentsMargins(0,0,20,0);

    // lhs buttons
    QHBoxLayout *lb = new QHBoxLayout(macAnalButtons);
    lb->setContentsMargins(0,0,0,0);
    lb->setSpacing(0);
    import = new QtMacButton(this, QtMacButton::TexturedRounded);
    QPixmap *importImg = new QPixmap(":images/mac/download.png");
    import->setImage(importImg);
    import->setToolTip("Download");
    lb->addWidget(import);
    lb->addWidget(new Spacer(this));
    compose = new QtMacButton(this, QtMacButton::TexturedRounded);
    QPixmap *composeImg = new QPixmap(":images/mac/compose.png");
    compose->setImage(composeImg);
    compose->setToolTip("Create");
    lb->addWidget(compose);

    // connect to actions
    connect(import, SIGNAL(clicked(bool)), this, SLOT(downloadRide()));
    connect(compose, SIGNAL(clicked(bool)), this, SLOT(manualRide()));

    lb->addWidget(new Spacer(this));

    // activity actions .. peaks, split, delete
    QWidget *acts = new QWidget(this);
    acts->setContentsMargins(0,0,0,0);
    QHBoxLayout *pp = new QHBoxLayout(acts);
    pp->setContentsMargins(0,0,0,0);
    pp->setContentsMargins(0,0,0,0);
    pp->setSpacing(5);
    sidebar = new QtMacButton(this, QtMacButton::TexturedRounded);
    QPixmap *sidebarImg = new QPixmap(":images/mac/sidebar.png");
    sidebar->setImage(sidebarImg);
    sidebar->setMinimumSize(25, 25);
    sidebar->setMaximumSize(25, 25);
    sidebar->setToolTip("Sidebar");
    sidebar->setSelected(true); // assume always start up with sidebar selected

    actbuttons = new QtMacSegmentedButton(3, acts);
    actbuttons->setWidth(115);
    actbuttons->setNoSelect();
    actbuttons->setImage(0, new QPixmap(":images/mac/stop.png"));
    actbuttons->setImage(1, new QPixmap(":images/mac/split.png"));
    actbuttons->setImage(2, new QPixmap(":images/mac/trash.png"));
    pp->addWidget(actbuttons);
    lb->addWidget(acts);
    lb->addStretch();
    connect(actbuttons, SIGNAL(clicked(int,bool)), this, SLOT(actionClicked(int)));

    lb->addWidget(new Spacer(this));

    QWidget *viewsel = new QWidget(this);
    viewsel->setContentsMargins(0,0,0,0);
    QHBoxLayout *pq = new QHBoxLayout(viewsel);
    pq->setContentsMargins(0,0,0,0);
    pq->setSpacing(5);
    pq->addWidget(sidebar);
    styleSelector = new QtMacSegmentedButton(2, viewsel);
    styleSelector->setWidth(80); // actually its 80 but we want a 30px space between is and the searchbox
    styleSelector->setImage(0, new QPixmap(":images/mac/tabbed.png"), 24);
    styleSelector->setImage(1, new QPixmap(":images/mac/tiled.png"), 24);
    pq->addWidget(styleSelector);
    connect(sidebar, SIGNAL(clicked(bool)), this, SLOT(toggleSidebar()));
    connect(styleSelector, SIGNAL(clicked(int,bool)), this, SLOT(toggleStyle()));

    // setup Mac thetoolbar
    head->addWidget(macAnalButtons);
    head->addWidget(new Spacer(this));
    head->addWidget(new Spacer(this));
    head->addWidget(viewsel);

#ifdef GC_HAVE_LUCENE
    SearchFilterBox *searchBox = new SearchFilterBox(this,context,false);
    QCleanlooksStyle *toolStyle = new QCleanlooksStyle();
    searchBox->setStyle(toolStyle);
    searchBox->setFixedWidth(200);
    head->addWidget(searchBox);
    connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(setFilter(QStringList)));
    connect(searchBox, SIGNAL(searchClear()), this, SLOT(clearFilter()));
#endif

#endif 

    /*----------------------------------------------------------------------
     *  Windows and Linux Toolbar
     *--------------------------------------------------------------------*/
#ifndef Q_OS_MAC

    head = new GcToolBar(this);

    QCleanlooksStyle *toolStyle = new QCleanlooksStyle();
    QPalette metal;
    metal.setColor(QPalette::Button, QColor(215,215,215));

    // get those icons
    importIcon = iconFromPNG(":images/mac/download.png");
    composeIcon = iconFromPNG(":images/mac/compose.png");
    intervalIcon = iconFromPNG(":images/mac/stop.png");
    splitIcon = iconFromPNG(":images/mac/split.png");
    deleteIcon = iconFromPNG(":images/mac/trash.png");
    sidebarIcon = iconFromPNG(":images/mac/sidebar.png");
    tabbedIcon = iconFromPNG(":images/mac/tabbed.png");
    tiledIcon = iconFromPNG(":images/mac/tiled.png");
    QSize isize(19,19);

    Spacer *spacerl = new Spacer(this);
    spacerl->setFixedWidth(5);

    import = new QPushButton(this);
    import->setIcon(importIcon);
    import->setIconSize(isize);
    import->setFixedHeight(25);
    import->setStyle(toolStyle);
    import->setToolTip(tr("Download from Device"));
    import->setPalette(metal);
    connect(import, SIGNAL(clicked(bool)), this, SLOT(downloadRide()));

    compose = new QPushButton(this);
    compose->setIcon(composeIcon);
    compose->setIconSize(isize);
    compose->setFixedHeight(25);
    compose->setStyle(toolStyle);
    compose->setToolTip(tr("Create Manual Activity"));
    compose->setPalette(metal);
    connect(compose, SIGNAL(clicked(bool)), this, SLOT(manualRide()));

    sidebar = new QPushButton(this);
    sidebar->setIcon(sidebarIcon);
    sidebar->setIconSize(isize);
    sidebar->setFixedHeight(25);
    sidebar->setStyle(toolStyle);
    sidebar->setToolTip(tr("Toggle Sidebar"));
    sidebar->setPalette(metal);
    connect(sidebar, SIGNAL(clicked(bool)), this, SLOT(toggleSidebar()));

    actbuttons = new QtSegmentControl(this);
    actbuttons->setStyle(toolStyle);
    actbuttons->setIconSize(isize);
    actbuttons->setCount(3);
    actbuttons->setSegmentIcon(0, intervalIcon);
    actbuttons->setSegmentIcon(1, splitIcon);
    actbuttons->setSegmentIcon(2, deleteIcon);
    actbuttons->setSelectionBehavior(QtSegmentControl::SelectNone); //wince. spelling. ugh
    actbuttons->setFixedHeight(25);
    actbuttons->setSegmentToolTip(0, tr("Find Intervals..."));
    actbuttons->setSegmentToolTip(1, tr("Split Activity..."));
    actbuttons->setSegmentToolTip(2, tr("Delete Activity"));
    actbuttons->setPalette(metal);
    connect(actbuttons, SIGNAL(segmentSelected(int)), this, SLOT(actionClicked(int)));

    styleSelector = new QtSegmentControl(this);
    styleSelector->setStyle(toolStyle);
    styleSelector->setIconSize(isize);
    styleSelector->setCount(2);
    styleSelector->setSegmentIcon(0, tabbedIcon);
    styleSelector->setSegmentIcon(1, tiledIcon);
    styleSelector->setSegmentToolTip(0, tr("Tabbed View"));
    styleSelector->setSegmentToolTip(1, tr("Tiled View"));
    styleSelector->setSelectionBehavior(QtSegmentControl::SelectOne); //wince. spelling. ugh
    styleSelector->setFixedHeight(25);
    styleSelector->setPalette(metal);
    connect(styleSelector, SIGNAL(segmentSelected(int)), this, SLOT(setStyleFromSegment(int))); //avoid toggle infinitely

    head->addWidget(spacerl);
    head->addWidget(import);
    head->addWidget(compose);
    head->addWidget(actbuttons);

    head->addStretch();
    head->addWidget(sidebar);
    head->addWidget(styleSelector);

#ifdef GC_HAVE_LUCENE
    // add a search box on far right, but with a little space too
    SearchFilterBox *searchBox = new SearchFilterBox(this,context,false);
    searchBox->setStyle(toolStyle);
    searchBox->setFixedWidth(200);
    head->addWidget(searchBox);
    connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(setFilter(QStringList)));
    connect(searchBox, SIGNAL(searchClear()), this, SLOT(clearFilter()));
#endif
    Spacer *spacer = new Spacer(this);
    spacer->setFixedWidth(5);
    head->addWidget(spacer);
#endif

    /*----------------------------------------------------------------------
     * ScopeBar
     *--------------------------------------------------------------------*/
    scopebar = new GcScopeBar(context);
    connect(scopebar, SIGNAL(selectDiary()), this, SLOT(selectDiary()));
    connect(scopebar, SIGNAL(selectHome()), this, SLOT(selectHome()));
    connect(scopebar, SIGNAL(selectAnal()), this, SLOT(selectAnalysis()));
    connect(scopebar, SIGNAL(selectTrain()), this, SLOT(selectTrain()));

    // Add chart is on the scope bar
    chartMenu = new QMenu(this);
    QCleanlooksStyle *styler = new QCleanlooksStyle();
    QPushButton *newchart = new QPushButton("+", this);
    scopebar->addWidget(newchart);
    newchart->setStyle(styler);
    newchart->setFixedHeight(20);
    newchart->setFixedWidth(24);
    newchart->setFlat(true);
    newchart->setFocusPolicy(Qt::NoFocus);
    newchart->setToolTip(tr("Add Chart"));
    newchart->setAutoFillBackground(false);
    newchart->setAutoDefault(false);
    newchart->setMenu(chartMenu);
    connect(chartMenu, SIGNAL(aboutToShow()), this, SLOT(setChartMenu()));
    connect(chartMenu, SIGNAL(triggered(QAction*)), this, SLOT(addChart(QAction*)));

    /*----------------------------------------------------------------------
     * Central Widget
     *--------------------------------------------------------------------*/

    tab = new Tab(context);

    /*----------------------------------------------------------------------
     * Central Widget
     *--------------------------------------------------------------------*/

    QWidget *central = new QWidget(this);
    setContentsMargins(0,0,0,0);
    central->setContentsMargins(0,0,0,0);
    QVBoxLayout *mainLayout = new QVBoxLayout(central);
    mainLayout->setSpacing(0);
    mainLayout->setContentsMargins(0,0,0,0);
#ifndef Q_OS_MAC // nonmac toolbar on main view -- its not 
                 // unified with the title bar.
    mainLayout->addWidget(head);
#endif
    mainLayout->addWidget(scopebar);
    mainLayout->addWidget(tab);
    setCentralWidget(central);

    /*----------------------------------------------------------------------
     * Application Menus
     *--------------------------------------------------------------------*/
#ifdef WIN32
    menuBar()->setStyleSheet("QMenuBar { background: rgba(225,225,225); }"
		    	     "QMenuBar::item { background: rgba(225,225,225); }");
    menuBar()->setContentsMargins(0,0,0,0);
#endif

    QMenu *fileMenu = menuBar()->addMenu(tr("&Athlete"));
    fileMenu->addAction(tr("&New..."), this, SLOT(newCyclist()), tr("Ctrl+N"));
    fileMenu->addAction(tr("&Open..."), this, SLOT(openCyclist()), tr("Ctrl+O"));
    fileMenu->addAction(tr("&Close Window"), this, SLOT(close()), tr ("Ctrl+W"));
    fileMenu->addAction(tr("&Quit All Windows"), this, SLOT(closeAll()), tr("Ctrl+Q"));

    QMenu *rideMenu = menuBar()->addMenu(tr("A&ctivity"));
    rideMenu->addAction(tr("&Download from device..."), this, SLOT(downloadRide()), tr("Ctrl+D"));
    rideMenu->addAction(tr("&Import from file..."), this, SLOT (importFile()), tr ("Ctrl+I"));
    rideMenu->addAction(tr("&Manual activity entry..."), this, SLOT(manualRide()), tr("Ctrl+M"));
    rideMenu->addSeparator ();
    rideMenu->addAction(tr("&Export..."), this, SLOT(exportRide()), tr("Ctrl+E"));
    rideMenu->addAction(tr("&Batch export..."), this, SLOT(exportBatch()), tr("Ctrl+B"));
    rideMenu->addAction(tr("Export Metrics as CSV..."), this, SLOT(exportMetrics()), tr(""));
#ifdef GC_HAVE_SOAP
    rideMenu->addSeparator ();
    rideMenu->addAction(tr("&Upload to TrainingPeaks"), this, SLOT(uploadTP()), tr("Ctrl+U"));
    rideMenu->addAction(tr("Down&load from TrainingPeaks..."), this, SLOT(downloadTP()), tr("Ctrl+L"));
#endif

#ifdef GC_HAVE_LIBOAUTH
    tweetAction = new QAction(tr("Tweet Activity"), this);
    connect(tweetAction, SIGNAL(triggered(bool)), this, SLOT(tweetRide()));
    rideMenu->addAction(tweetAction);

    shareAction = new QAction(tr("Share (Strava, RideWithGPS, CyclingAnalytics)..."), this);
    connect(shareAction, SIGNAL(triggered(bool)), this, SLOT(share()));
    rideMenu->addAction(shareAction);
#endif

    ttbAction = new QAction(tr("Upload to Trainingstagebuch..."), this);
    connect(ttbAction, SIGNAL(triggered(bool)), this, SLOT(uploadTtb()));
    rideMenu->addAction(ttbAction);

    rideMenu->addSeparator ();
    rideMenu->addAction(tr("&Save activity"), this, SLOT(saveRide()), tr("Ctrl+S"));
    rideMenu->addAction(tr("D&elete activity..."), this, SLOT(deleteRide()));
    rideMenu->addAction(tr("Split &activity..."), this, SLOT(splitRide()));
    rideMenu->addAction(tr("Merge activities..."), this, SLOT(mergeRide()));
    rideMenu->addSeparator ();

    QMenu *optionsMenu = menuBar()->addMenu(tr("&Tools"));
    optionsMenu->addAction(tr("&Options..."), this, SLOT(showOptions()));
    optionsMenu->addAction(tr("Critical Power Estimator..."), this, SLOT(showTools()));
    optionsMenu->addAction(tr("Air Density (Rho) Estimator..."), this, SLOT(showRhoEstimator()));

    optionsMenu->addSeparator();
    optionsMenu->addAction(tr("Get &Withings Data..."), this,
                        SLOT (downloadMeasures()));
    optionsMenu->addAction(tr("Get &Zeo Data..."), this,
                        SLOT (downloadMeasuresFromZeo()));
    optionsMenu->addSeparator();
    optionsMenu->addAction(tr("Create a new workout..."), this, SLOT(showWorkoutWizard()));
    optionsMenu->addAction(tr("Download workouts from ErgDB..."), this, SLOT(downloadErgDB()));
    optionsMenu->addAction(tr("Import workouts or videos..."), this, SLOT(importWorkout()));
    optionsMenu->addAction(tr("Scan disk for videos and workouts..."), this, SLOT(manageLibrary()));

#ifdef GC_HAVE_ICAL
    optionsMenu->addSeparator();
    optionsMenu->addAction(tr("Upload Activity to Calendar"), this, SLOT(uploadCalendar()), tr (""));
    //optionsMenu->addAction(tr("Import Calendar..."), this, SLOT(importCalendar()), tr ("")); // planned for v3.1
    //optionsMenu->addAction(tr("Export Calendar..."), this, SLOT(exportCalendar()), tr ("")); // planned for v3.1
    optionsMenu->addAction(tr("Refresh Calendar"), this, SLOT(refreshCalendar()), tr (""));
#endif
    optionsMenu->addSeparator();
    optionsMenu->addAction(tr("Find intervals..."), this, SLOT(addIntervals()), tr (""));

    // Add all the data processors to the tools menu
    const DataProcessorFactory &factory = DataProcessorFactory::instance();
    QMap<QString, DataProcessor*> processors = factory.getProcessors();

    if (processors.count()) {

        optionsMenu->addSeparator();
        toolMapper = new QSignalMapper(this); // maps each option
        QMapIterator<QString, DataProcessor*> i(processors);
        connect(toolMapper, SIGNAL(mapped(const QString &)), this, SLOT(manualProcess(const QString &)));

        i.toFront();
        while (i.hasNext()) {
            i.next();
            // The localized processor name is shown in menu
            QAction *action = new QAction(QString("%1...").arg(i.value()->name()), this);
            optionsMenu->addAction(action);
            connect(action, SIGNAL(triggered()), toolMapper, SLOT(map()));
            toolMapper->setMapping(action, i.key());
        }
    }
Example #19
0
/** Constructor */
SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareDirModel *_flat_model,QWidget *parent)
: RsAutoUpdatePage(1000,parent),model(NULL)
{
	/* Invoke the Qt Designer generated object setup routine */
	ui.setupUi(this);

	NotifyQt *notify = NotifyQt::getInstance();
	connect(notify, SIGNAL(filesPreModChanged(bool)), this, SLOT(preModDirectories(bool)));
	connect(notify, SIGNAL(filesPostModChanged(bool)), this, SLOT(postModDirectories(bool)));

//==	connect(ui.localButton, SIGNAL(toggled(bool)), this, SLOT(showFrame(bool)));
//==	connect(ui.remoteButton, SIGNAL(toggled(bool)), this, SLOT(showFrameRemote(bool)));
//==	connect(ui.splittedButton, SIGNAL(toggled(bool)), this, SLOT(showFrameSplitted(bool)));
	connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int)));

	connect( ui.dirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this,  SLOT( spawnCustomPopupMenu( QPoint ) ) );

	connect(ui.indicatorCBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indicatorChanged(int)));

	tree_model = _tree_model ;
	flat_model = _flat_model ;

	tree_proxyModel = new SFDSortFilterProxyModel(tree_model, this);
	tree_proxyModel->setSourceModel(tree_model);
	tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
	tree_proxyModel->setSortRole(RetroshareDirModel::SortRole);
	tree_proxyModel->sort(COLUMN_NAME);

    flat_proxyModel = new SFDSortFilterProxyModel(flat_model, this);
    flat_proxyModel->setSourceModel(flat_model);
    flat_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
    flat_proxyModel->setSortRole(RetroshareDirModel::SortRole);
    flat_proxyModel->sort(COLUMN_NAME);

    // Mr.Alice: I removed this because it causes a crash for some obscur reason. Apparently when the model is changed, the proxy model cannot
    // deal with the change by itself. Should I call something specific? I've no idea. Removing this does not seem to cause any harm either.
    //tree_proxyModel->setDynamicSortFilter(true);
    //flat_proxyModel->setDynamicSortFilter(true);

    connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
	connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter()));
	connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter()));
	connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));

	/* Set header resize modes and initial section sizes  */
	QHeaderView * header = ui.dirTreeView->header () ;

	header->resizeSection ( COLUMN_NAME, 490 );
    header->resizeSection ( COLUMN_SIZE, 70  );
    header->resizeSection ( COLUMN_AGE, 100  );
    header->resizeSection ( COLUMN_FRIEND,100);
    header->resizeSection ( COLUMN_DIR, 100  );

	header->setStretchLastSection(false);

	/* Set Multi Selection */
	ui.dirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);

  /* Hide platform specific features */
  copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard" ), this );
  connect( copylinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) );
  copylinkhtmlAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard (HTML)" ), this );
  connect( copylinkhtmlAct , SIGNAL( triggered() ), this, SLOT( copyLinkhtml() ) );
  sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links" ), this );
  connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( ) ) );
#ifdef RS_USE_LINKS
  sendlinkCloudAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links to Cloud" ), this );
  connect( sendlinkCloudAct , SIGNAL( triggered() ), this, SLOT( sendLinkToCloud(  ) ) );
  addlinkCloudAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Add Links to Cloud" ), this );
  connect( addlinkCloudAct , SIGNAL( triggered() ), this, SLOT( addLinkToCloud(  ) ) );
#endif

	collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this) ;
	connect(collCreateAct,SIGNAL(triggered()),this,SLOT(collCreate())) ;
	collModifAct= new QAction(QIcon(IMAGE_COLLMODIF), tr("Modify Collection..."), this) ;
	connect(collModifAct,SIGNAL(triggered()),this,SLOT(collModif())) ;
	collViewAct= new QAction(QIcon(IMAGE_COLLVIEW), tr("View Collection..."), this) ;
	connect(collViewAct,SIGNAL(triggered()),this,SLOT(collView())) ;
	collOpenAct = new QAction(QIcon(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this ) ;
	connect(collOpenAct, SIGNAL(triggered()), this, SLOT(collOpen())) ;
}
Example #20
0
void MediaBrowser::setupUI()
{
	QVBoxLayout *vbox0 = new QVBoxLayout(this);
	m_splitter = new QSplitter(this);
	m_splitter->setOrientation(Qt::Vertical);
	vbox0->addWidget(m_splitter);

	QWidget *browser = new QWidget(m_splitter);
	QVBoxLayout *vbox = new QVBoxLayout(browser);
	SET_MARGIN(vbox,0);

	// Setup filter box at the top of the widget
	m_searchBase = new QWidget(browser);

	QHBoxLayout *hbox = new QHBoxLayout(m_searchBase);
	SET_MARGIN(hbox,0);

	m_btnBack = new QPushButton(QIcon(":/data/stock-go-back.png"),"");
	m_btnBack->setEnabled(false);
	connect(m_btnBack, SIGNAL(clicked()), this, SLOT(goBack()));

	m_btnForward = new QPushButton(QIcon(":/data/stock-go-forward.png"),"");
	m_btnForward->setEnabled(false);
	connect(m_btnForward, SIGNAL(clicked()), this, SLOT(goForward()));

	m_btnUp = new QPushButton(QIcon(":/data/stock-go-up.png"),"");
	m_btnUp->setEnabled(false);
	connect(m_btnUp, SIGNAL(clicked()), this, SLOT(goUp()));

	QLabel *label = new QLabel("Fil&ter:");
	m_searchBox = new QLineEdit(m_searchBase);
	label->setBuddy(m_searchBox);

	m_clearSearchBtn = new QPushButton(QIcon(":/data/stock-clear.png"),"");
	m_clearSearchBtn->setVisible(false);

	hbox->addWidget(m_btnBack);
	hbox->addWidget(m_btnForward);
	hbox->addWidget(m_btnUp);
	hbox->addWidget(label);
	hbox->addWidget(m_searchBox);
	hbox->addWidget(m_clearSearchBtn);

	connect(m_searchBox, SIGNAL(textChanged(const QString &)), this, SLOT(filterChanged(const QString &)));
	connect(m_searchBox, SIGNAL(returnPressed()), this, SLOT(filterReturnPressed()));
	connect(m_clearSearchBtn, SIGNAL(clicked()), this, SLOT(clearFilter()));
	
	// Now for the list itself
	m_listView = new MediaBrowserQListView(browser);
	m_listView->setAlternatingRowColors(true);
	m_listView->setIconSize(m_iconSize);
	//m_listView->setWrapping(true);
	m_listView->setWordWrap(true);
	//m_listView->setGridSize(MEDIABROWSER_LIST_ICON_SIZE);
	m_listView->setLayoutMode(QListView::Batched);
	//m_listView->setFlow(QListView::LeftToRight);
	m_listView->setResizeMode(QListView::Adjust);
	//m_listView->setSelectionMode(QAbstractItemView::SingleSelection);

	// below doesnt seem to be enough
	//m_listView->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed);

	m_fsModel = new DirectoryListModel(browser); //QFileSystemModel(browser);
	m_fsModel->setIconProvider(new MyQFileIconProvider());
	//m_fsModel->setNameFilterDisables(false);

	m_listView->setModel(m_fsModel);

	connect(m_listView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(indexDoubleClicked(const QModelIndex &)));
	connect(m_listView,     SIGNAL(activated(const QModelIndex &)), this, SLOT(indexDoubleClicked(const QModelIndex &)));
	connect(m_listView,       SIGNAL(clicked(const QModelIndex &)), this, SLOT(indexSingleClicked(const QModelIndex &)));

	////////////////////////
	
	// Add action buttons
	m_btnBase = new QWidget(browser);
	QHBoxLayout *hbox3 = new QHBoxLayout(m_btnBase);
	SET_MARGIN(hbox3,0);

	m_btnSetAsBgLive = new QPushButton(QIcon(":/data/stock-apply-ffwd.png"),"");
	m_btnSetAsBgLive->setToolTip("Set selected file as background for the current live slide");
	hbox3->addWidget(m_btnSetAsBgLive);

	m_btnAddToSchedue = new QPushButton(QIcon(":/data/stock-add.png"),"");
	m_btnAddToSchedue->setToolTip("Add selected file to schedule");
	hbox3->addWidget(m_btnAddToSchedue);

	m_btnSetAsBgLater = new QPushButton(QIcon(":/data/stock-apply-next.png"),"");
	m_btnSetAsBgLater->setToolTip("Set selected file as background for the NEXT slide to go live");
	hbox3->addWidget(m_btnSetAsBgLater);

	m_btnSetAsBgCurrent = new QPushButton(QIcon(":/data/stock-apply-pause.png"),"");
	m_btnSetAsBgCurrent->setToolTip("Set selected file as background for the selected slide group");
	hbox3->addWidget(m_btnSetAsBgCurrent);

	connect(m_btnAddToSchedue, SIGNAL(clicked()), this, SLOT(slotAddToSchedule()));
	connect(m_btnSetAsBgCurrent, SIGNAL(clicked()), this, SLOT(slotSetAsBgCurrent()));
	connect(m_btnSetAsBgLater, SIGNAL(clicked()), this, SLOT(slotSetAsBgLater()));
	connect(m_btnSetAsBgLive, SIGNAL(clicked()), this, SLOT(slotSetAsBgLive()));

	// enabled by indexSingleClicked()
	m_btnBase->setEnabled(false);
	
	/////////////////

	// Add the directory box and filter box at bottom
	m_folderBoxBase = new QWidget(browser);
	QHBoxLayout *hbox2 = new QHBoxLayout(m_folderBoxBase);
	SET_MARGIN(hbox2,0);
	
	hbox2->addWidget(new QLabel("Folder:"));
	
	m_dirBox = new QLineEdit(m_folderBoxBase);
	hbox2->addWidget(m_dirBox);
	
	m_filterBox = new QComboBox(m_folderBoxBase);
	hbox2->addWidget(m_filterBox);

	connect(m_dirBox, SIGNAL(returnPressed()), this, SLOT(dirBoxReturnPressed()));
	connect(m_filterBox, SIGNAL(currentIndexChanged(int)), this, SLOT(fileTypeChanged(int)));
	
	//#######################################333
	
	
	m_bookmarkBase = new QWidget(browser);
	
	QHBoxLayout *hbox4 = new QHBoxLayout(m_bookmarkBase);
	SET_MARGIN(hbox4,0);
	
	hbox4->addWidget(new QLabel("Saved:"));
	
	m_bookmarkBox = new QComboBox(m_bookmarkBase);
	hbox4->addWidget(m_bookmarkBox,2);

	m_btnBookmark = new QPushButton(QIcon(":/data/stock-new.png"),"");
	m_btnBookmark->setToolTip("Bookmark current folder");
	hbox4->addWidget(m_btnBookmark);
	
	m_btnDelBookmark = new QPushButton(QIcon(":/data/stock-remove.png"),"");
	m_btnDelBookmark->setToolTip("Delete current bookmark");
	hbox4->addWidget(m_btnDelBookmark);
	
	connect(m_bookmarkBox, SIGNAL(activated(int)), this, SLOT(loadBookmarkIndex(int)));
	connect(m_btnBookmark, SIGNAL(clicked()), this, SLOT(slotBookmarkFolder()));
	connect(m_btnDelBookmark, SIGNAL(clicked()), this, SLOT(slotDelBookmark()));
	
	
	//#######################################333
	


	QFrame * line = new QFrame();
        line->setFrameShape(QFrame::HLine);
        line->setFrameShadow(QFrame::Sunken);
	
	vbox->addWidget(m_searchBase);
	vbox->addWidget(m_folderBoxBase);
	vbox->addWidget(line);
	vbox->addWidget(m_bookmarkBase);
	vbox->addWidget(m_listView);
	vbox->addWidget(m_btnBase);
	
	m_splitter->addWidget(browser);

	m_viewerBase = new QWidget(m_splitter);
	m_viewerLayout = new QVBoxLayout(m_viewerBase);
	m_viewerLayout->setContentsMargins(0,0,0,0);
	
	// Setup the slide group viewer
	m_viewer = new SlideGroupViewer(m_viewerBase);
	m_viewer->setCanZoom(true);
	m_viewer->setSceneContextHint(MyGraphicsScene::Preview);
	m_viewer->setBackground(Qt::black);

	// Create the slide and slide group that we'll reuse to preview the 
	// selected media items
	Slide * slide = new Slide();
	AbstractVisualItem * bg = dynamic_cast<AbstractVisualItem*>(slide->background());
	bg->setFillType(AbstractVisualItem::Solid);
	bg->setFillBrush(Qt::black);

	SlideGroup *group = new SlideGroup();
	group->addSlide(slide);
	
	//qDebug() << "MediaBrowser::setupUI(): Setting slidegroup "<<group<<" on viewer "<<m_viewer; 
	m_viewer->setSlideGroup(group, slide);
	
	m_viewerLayout->addWidget(m_viewer);
	m_splitter->addWidget(m_viewerBase);
	
	loadBookmarks();
}
CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent, bool rangemode) :
    GcWindow(parent), _dateRange("{00000000-0000-0000-0000-000000000001}"), home(home), mainWindow(parent), currentRide(NULL), rangemode(rangemode), stale(true), useCustom(false)
{
    setInstanceName("Critical Power Window");

    // main plot area
    QVBoxLayout *vlayout = new QVBoxLayout;
    cpintPlot = new CpintPlot(mainWindow, home.path(), mainWindow->zones());
    vlayout->addWidget(cpintPlot);
    setLayout(vlayout);

    // controls
    QWidget *c = new QWidget;
    QFormLayout *cl = new QFormLayout(c);
    setControls(c);

#ifdef GC_HAVE_LUCENE
    // searchbox
    searchBox = new SearchFilterBox(this, parent);
    connect(searchBox, SIGNAL(searchClear()), cpintPlot, SLOT(clearFilter()));
    connect(searchBox, SIGNAL(searchResults(QStringList)), cpintPlot, SLOT(setFilter(QStringList)));
    connect(searchBox, SIGNAL(searchClear()), this, SLOT(filterChanged()));
    connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(filterChanged()));
    cl->addRow(new QLabel(tr("Filter")), searchBox);
    cl->addWidget(new QLabel("")); //spacing
#endif

    // picker details
    QLabel *cpintTimeLabel = new QLabel(tr("Duration:"), this);
    cpintTimeValue = new QLineEdit("0 s");
    QLabel *cpintTodayLabel = new QLabel(tr("Today:"), this);
    cpintTodayValue = new QLabel(tr("no data"));
    QLabel *cpintAllLabel = new QLabel(tr("Best:"), this);
    cpintAllValue = new QLabel(tr("no data"));
    QLabel *cpintCPLabel = new QLabel(tr("CP Curve:"), this);
    cpintCPValue = new QLabel(tr("no data"));

    //QFontMetrics metrics(QApplication::font());
    //int width = metrics.width("8888 watts (88/88/8888)") + 10;
    //cpintAllValue->setFixedWidth(width);
    //cpintCPValue->setFixedWidth(width); // so lines up nicely

    cpintTimeValue->setReadOnly(false);
    //cpintTodayValue->setReadOnly(true);
    //cpintAllValue->setReadOnly(true);
    //cpintCPValue->setReadOnly(true);

    QFont font = cpintTimeValue->font();
    font.setPointSize(font.pointSize());
    cpintTodayValue->setFont(font);
    cpintAllValue->setFont(font);
    cpintCPValue->setFont(font);

    cl->addRow(cpintTimeLabel, cpintTimeValue);
    cl->addRow(cpintTodayLabel, cpintTodayValue);
    cl->addRow(cpintAllLabel, cpintAllValue);
    cl->addRow(cpintCPLabel, cpintCPValue);
    cl->addWidget(new QLabel("")); //spacing

    // tools /properties
    seriesCombo = new QComboBox(this);
    addSeries();
    cComboSeason = new QComboBox(this);
    seasons = parent->seasons;
    resetSeasons();
    QLabel *label = new QLabel(tr("Date range"));
    QLabel *label2 = new QLabel(tr("Date range"));
    if (rangemode) {
        cComboSeason->hide();
        label2->hide();
    }

    cpintSetCPButton = new QPushButton(tr("&Save CP value"), this);
    cpintSetCPButton->setEnabled(false);
    cl->addRow(label2, cComboSeason);

    dateSetting = new DateSettingsEdit(this);
    cl->addRow(label, dateSetting);

    if (rangemode == false) {
        dateSetting->hide();
        label->hide();
    }

    cl->addWidget(new QLabel("")); //spacing
    cl->addRow(new QLabel(tr("Data series")), seriesCombo);
    cl->addRow(new QLabel(""), cpintSetCPButton);

    picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
                               QwtPicker::VLineRubberBand,
                               QwtPicker::AlwaysOff, cpintPlot->canvas());
    picker->setStateMachine(new QwtPickerDragPointMachine);
    picker->setRubberBandPen(GColor(CPLOTTRACKER));

    connect(picker, SIGNAL(moved(const QPoint &)), SLOT(pickerMoved(const QPoint &)));
    connect(cpintTimeValue, SIGNAL(editingFinished()), this, SLOT(cpintTimeValueEntered()));
    connect(cpintSetCPButton, SIGNAL(clicked()), this, SLOT(cpintSetCPButtonClicked()));
    if (rangemode) {
        connect(this, SIGNAL(dateRangeChanged(DateRange)), SLOT(dateRangeChanged(DateRange)));
    } else {
        connect(cComboSeason, SIGNAL(currentIndexChanged(int)), this, SLOT(seasonSelected(int)));
    }

    connect(seriesCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setSeries(int)));
    //connect(mainWindow, SIGNAL(rideSelected()), this, SLOT(rideSelected()));
    connect(this, SIGNAL(rideItemChanged(RideItem*)), this, SLOT(rideSelected()));
    connect(mainWindow, SIGNAL(configChanged()), cpintPlot, SLOT(configChanged()));

    // redraw on config change -- this seems the simplest approach
    connect(mainWindow, SIGNAL(configChanged()), this, SLOT(rideSelected()));
    connect(mainWindow, SIGNAL(rideAdded(RideItem*)), this, SLOT(newRideAdded(RideItem*)));
    connect(mainWindow, SIGNAL(rideDeleted(RideItem*)), this, SLOT(newRideAdded(RideItem*)));
    connect(seasons, SIGNAL(seasonsChanged()), this, SLOT(resetSeasons()));

    connect(dateSetting, SIGNAL(useCustomRange(DateRange)), this, SLOT(useCustomRange(DateRange)));
    connect(dateSetting, SIGNAL(useThruToday()), this, SLOT(useThruToday()));
    connect(dateSetting, SIGNAL(useStandardRange()), this, SLOT(useStandardRange()));
}
FILTER::FILTER() {
	clearFilter();
}
Example #23
0
void KexiFileWidget::updateFilters()
{
    if (d->filtersUpdated)
        return;
    d->filtersUpdated = true;
    d->lastFileName.clear();
    clearFilter();

    QString filter;
    KMimeType::Ptr mime;
    QStringList allfilters;

    const bool normalOpeningMode = d->mode & Opening && !(d->mode & Custom);
    const bool normalSavingMode = d->mode & SavingFileBasedDB && !(d->mode & Custom);

    if (normalOpeningMode || normalSavingMode) {
        mime = KMimeType::mimeType(KexiDB::defaultFileBasedDriverMimeType());
        if (mime && !d->excludedMimeTypes.contains(mime->name().toLower())) {
            filter += KexiUtils::fileDialogFilterString(mime);
            allfilters += mime->patterns();
        }
    }
    if (normalOpeningMode || d->mode & SavingServerBasedDB) {
        mime = KMimeType::mimeType("application/x-kexiproject-shortcut");
        if (mime && !d->excludedMimeTypes.contains(mime->name().toLower())) {
            filter += KexiUtils::fileDialogFilterString(mime);
            allfilters += mime->patterns();
        }
    }
    if (normalOpeningMode || d->mode & SavingServerBasedDB) {
        mime = KMimeType::mimeType("application/x-kexi-connectiondata");
        if (mime && !d->excludedMimeTypes.contains(mime->name().toLower())) {
            filter += KexiUtils::fileDialogFilterString(mime);
            allfilters += mime->patterns();
        }
    }

//! @todo hardcoded for MSA:
    if (normalOpeningMode) {
        mime = KMimeType::mimeType("application/vnd.ms-access");
        if (mime && !d->excludedMimeTypes.contains(mime->name().toLower())) {
            filter += KexiUtils::fileDialogFilterString(mime);
            allfilters += mime->patterns();
        }
        mime = KMimeType::mimeType("application/vnd.oasis.opendocument.database");
        if (mime && !d->excludedMimeTypes.contains(mime->name().toLower())) {
            filter += KexiUtils::fileDialogFilterString(mime);
            allfilters += mime->patterns();
        }
    }

    foreach(const QString& mimeName, d->additionalMimeTypes) {
        if (mimeName == "all/allfiles")
            continue;
        if (d->excludedMimeTypes.contains(mimeName.toLower()))
            continue;
        filter += KexiUtils::fileDialogFilterString(mimeName);
        mime = KMimeType::mimeType(mimeName);
        allfilters += mime->patterns();
    }

    if (!d->excludedMimeTypes.contains("all/allfiles")) {
        filter += filterWidget()->defaultFilter();
    }

    //remove duplicates made because upper- and lower-case extenstions are used:
    QStringList allfiltersUnique = allfilters.toSet().toList();
    qSort(allfiltersUnique);

    if (allfiltersUnique.count() > 1) {//prepend "all supoported files" entry
        filter.prepend(allfilters.join(" ") + "|"
                       + i18n("All Supported Files (%1)", allfiltersUnique.join(", ")) + "\n");
    }

    if (filter.right(1) == "\n")
        filter.truncate(filter.length() - 1);
    setFilter(filter);

    if (d->mode & Opening) {
        KFileWidget::setMode(KFile::ExistingOnly | KFile::LocalOnly | KFile::File);
        setOperationMode(KFileWidget::Opening);
    } else {
        KFileWidget::setMode(KFile::LocalOnly | KFile::File);
        setOperationMode(KFileWidget::Saving);
    }
}
bool FILTER::setFilter(std::string filter) {
	//Clears variables before setting them
	clearFilter();

	//Initializes Syntax as good
	bool syntaxCheck = true;
	std::stringstream ss(filter); //Separates commands by spaces
	std::istringstream intConv; //Used for converting string numbers to type int
	std::string buff; //General string buffer
	std::string args; //Holds arguments for commandsf
	std::vector<std::string> commands; //Holds all commands

	//Separates commands by spaces and inputs them into list
	while(ss >> buff) {
		commands.push_back(buff);
	}

	//Parse each command
	if(commands.size() != 0)
	for(int i = 0; i <= (commands.size() - 1); i++) {
		buff.clear();
		args.clear();
		
		//Initial syntax check for '='; All commands should have this
		if((commands[i]).find_first_of("=") == std::string::npos) {
			syntaxCheck = false;
			break;
		}
		else //Split command into filter type and value
			for(size_t q = 0; q <= commands[i].find_first_of("=") - 1; q++)
				buff += commands[i].at(q);
			for(int q = commands[i].find_first_of("=") + 1;
				 	q <= ((commands[i]).size()-1); q++)
				args += commands[i].at(q);
		
		//Input values into variables
		if(buff.compare("time" ) == 0) {
			//Synatx check
			if(args.find_first_of("-")==std::string::npos) {
				syntaxCheck = false;
				break;
			}
			else { //Split start and end time
				filterTime = true;
				for(int q = 0; q <= args.find_first_of("-") - 1; q++)
					startTime += args.at(q);
				for(int q = args.find_first_of("-") + 1;
		 				q <= (args.size()-1); q++)
					endTime += args.at(q);
			}
		}
		else if(buff.compare("date") == 0) {
			//Syntax check
			if(args.find_first_of("-")==std::string::npos) {
				syntaxCheck = false;
				break;
			}
			else { //Split start and end date
				filterDate = true;
				for(int q = 0; q <= args.find_first_of("-"); q++)
					startDate += args.at(q);
				for(int q = args.find_first_of("-") + 1;
		 				q <= (args.size()-1); q++)
					endDate += args.at(q);
			}
		}
		else if(buff.compare("days") == 0) {
			filterDay = true;
			//Relplaces commas with spaces
			for(size_t q = args.find_first_of(",");
					q != std::string::npos; q = args.find_first_of(",", ++q)) {
				args[q] = ' ';
			}

			buff.clear();
			ss.clear();
			ss.str(args);

			//Puts days into vector based on spaces
			while(ss >> buff)
				matchDays.push_back(buff);
		}
		else if(buff.compare("months") == 0) {
void
IntervalSidebar::filterChanged()
{
    if (context->isfiltered) setFilter(context->filters);
    else clearFilter();
}
Example #26
0
/** Constructor */
NetworkDialog::NetworkDialog(QWidget *parent)
: RsAutoUpdatePage(10000,parent) 	// updates every 10 sec.
{
    /* Invoke the Qt Designer generated object setup routine */
    ui.setupUi(this);
  
    connect( ui.connecttreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) );
    connect( ui.connecttreeWidget, SIGNAL( itemSelectionChanged()), ui.unvalidGPGkeyWidget, SLOT( clearSelection() ) );
    connect( ui.connecttreeWidget, SIGNAL( itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT( peerdetails () ) );
    connect( ui.unvalidGPGkeyWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) );
    connect( ui.unvalidGPGkeyWidget, SIGNAL( itemSelectionChanged()), ui.connecttreeWidget, SLOT( clearSelection() ) );
    connect( ui.unvalidGPGkeyWidget, SIGNAL( itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT( peerdetails () ) );

    connect( ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
    connect( ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged()));
    connect( ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));

    connect( ui.showUnvalidKeys, SIGNAL(clicked()), this, SLOT(insertConnect()));

    /* hide the Tree +/- */
    ui.connecttreeWidget -> setRootIsDecorated( false );
    ui.connecttreeWidget -> setColumnCount(5);
    ui.unvalidGPGkeyWidget-> setColumnCount(5);

    /* Set header resize modes and initial section sizes */
    QHeaderView * _header = ui.connecttreeWidget->header () ;
    _header->setResizeMode (0, QHeaderView::Custom);
    _header->setResizeMode (1, QHeaderView::Interactive);
    _header->setResizeMode (2, QHeaderView::Interactive);
    _header->setResizeMode (3, QHeaderView::Interactive);
    _header->setResizeMode (4, QHeaderView::Interactive);

    _header->resizeSection ( 0, 25 );
    _header->resizeSection ( 1, 200 );
    _header->resizeSection ( 2, 200 );
    _header->resizeSection ( 3, 200 );

    // set header text aligment
    QTreeWidgetItem * headerItem = ui.connecttreeWidget->headerItem();
    headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
    headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
    headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter);
    headerItem->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter);
    headerItem->setTextAlignment(4, Qt::AlignVCenter);

      /* hide the Tree +/- */
    ui.unvalidGPGkeyWidget -> setRootIsDecorated( false );

    /* Set header resize modes and initial section sizes */
    ui.unvalidGPGkeyWidget->header()->setResizeMode (0, QHeaderView::Custom);
    ui.unvalidGPGkeyWidget->header()->setResizeMode (1, QHeaderView::Interactive);
    ui.unvalidGPGkeyWidget->header()->setResizeMode (2, QHeaderView::Interactive);
    ui.unvalidGPGkeyWidget->header()->setResizeMode (3, QHeaderView::Interactive);
    ui.unvalidGPGkeyWidget->header()->setResizeMode (4, QHeaderView::Interactive);

    ui.unvalidGPGkeyWidget->header()->resizeSection ( 0, 25 );
    ui.unvalidGPGkeyWidget->header()->resizeSection ( 1, 200 );
    ui.unvalidGPGkeyWidget->header()->resizeSection ( 2, 200 );
    ui.unvalidGPGkeyWidget->header()->resizeSection ( 3, 200 );

    // set header text aligment
    ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
    ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
    ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter);
    ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter);
    ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(4, Qt::AlignVCenter);

    ui.connecttreeWidget->sortItems( 1, Qt::AscendingOrder );
    ui.unvalidGPGkeyWidget->sortItems( 1, Qt::AscendingOrder );

    ui.networkTab->addTab(new TrustView(),QString(tr("Authentication matrix")));
    ui.networkTab->addTab(networkview = new NetworkView(),QString(tr("Network View")));
    
    ui.showUnvalidKeys->setMinimumWidth(20);
     
    QString version = "-";
    std::map<std::string, std::string>::iterator vit;
    std::map<std::string, std::string> versions;
    bool retv = rsDisc->getDiscVersions(versions);
    if (retv && versions.end() != (vit = versions.find(rsPeers->getOwnId()))) {
    	version	= QString::fromStdString(vit->second);
    }
      
    QMenu *menu = new QMenu();
    //menu->addAction(ui.actionAddFriend); 
    //menu->addAction(ui.actionCopyKey);
    //menu->addAction(ui.actionExportKey);
    //menu->addAction(ui.actionCreate_New_Profile);
    //menu->addSeparator();
    menu->addAction(ui.actionTabsright); 
    menu->addAction(ui.actionTabswest);
    menu->addAction(ui.actionTabssouth); 
    menu->addAction(ui.actionTabsnorth);
    menu->addSeparator();
    menu->addAction(ui.actionTabsTriangular); 
    menu->addAction(ui.actionTabsRounded);
    ui.viewButton->setMenu(menu);
    
    QTimer *timer2 = new QTimer(this);
    connect(timer2, SIGNAL(timeout()), this, SLOT(updateNetworkStatus()));
    timer2->start(1000);
    
    updateNetworkStatus();
    loadtabsettings();
    
    ui.clearButton->hide();

  /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}
	statusBar->setStyleSheet("QStatusBar::item {border: none;}");
	statusBar->layout()->setMargin(0);
	statusBar->layout()->setSpacing(1);
	statusBar->layout()->setContentsMargins(0, 0, 0, 0);
	statusBar->setMaximumHeight(16);

	ui->mainLayout->addWidget(statusBar);

	QObject::connect(TextureConvertor::Instance(), SIGNAL(ConvertStatusImg(const QString&, int)), this, SLOT(convertStatusImg(const QString&, int)));
	QObject::connect(TextureConvertor::Instance(), SIGNAL(ConvertStatusQueue(int, int)), this, SLOT(convertStatusQueue(int, int)));
}

void TextureBrowser::setupTexturesList()
{
	QObject::connect(ui->listViewTextures, SIGNAL(selected(const QModelIndex &)), this, SLOT(texturePressed(const QModelIndex &)));
	QObject::connect(ui->clearFilterButton, SIGNAL(released()), this, SLOT(clearFilter()));

	ui->listViewTextures->setItemDelegate(textureListImagesDelegate);
	ui->listViewTextures->setModel(textureListModel);
}

void TextureBrowser::setupImagesScrollAreas()
{
	// pos change
	QObject::connect(ui->textureAreaOriginal, SIGNAL(texturePosChanged(const QPoint &)), ui->textureAreaConverted, SLOT(setTexturePos(const QPoint &)));
	QObject::connect(ui->textureAreaConverted, SIGNAL(texturePosChanged(const QPoint &)), ui->textureAreaOriginal, SLOT(setTexturePos(const QPoint &)));

	// mouse over pixel
	QObject::connect(ui->textureAreaOriginal, SIGNAL(mouseOverPixel(const QPoint &)), this, SLOT(texturePixelOver(const QPoint &)));
	QObject::connect(ui->textureAreaConverted, SIGNAL(mouseOverPixel(const QPoint &)), this, SLOT(texturePixelOver(const QPoint &)));
Example #28
0
DisplayFilterEdit::DisplayFilterEdit(QWidget *parent, DisplayFilterEditType type) :
    SyntaxLineEdit(parent),
    type_(type),
    bookmark_button_(NULL),
    clear_button_(NULL),
    apply_button_(NULL)
{
    setAccessibleName(tr("Display filter entry"));

    completion_model_ = new QStringListModel(this);
    setCompleter(new QCompleter(completion_model_, this));
    setCompletionTokenChars(fld_abbrev_chars_);

    setDefaultPlaceholderText();

    //   DFCombo
    //     Bookmark
    //     DisplayFilterEdit
    //     Clear button
    //     Apply (right arrow)
    //     Combo drop-down

    if (type_ == DisplayFilterToApply) {
        bookmark_button_ = new StockIconToolButton(this, "x-filter-bookmark");
        bookmark_button_->setCursor(Qt::ArrowCursor);
        bookmark_button_->setMenu(new QMenu());
        bookmark_button_->setPopupMode(QToolButton::InstantPopup);
        bookmark_button_->setToolTip(tr("Manage saved bookmarks."));
        bookmark_button_->setIconSize(QSize(14, 14));
        bookmark_button_->setStyleSheet(
                "QToolButton {"
                "  border: none;"
                "  background: transparent;" // Disables platform style on Windows.
                "  padding: 0 0 0 0;"
                "}"
                "QToolButton::menu-indicator { image: none; }"
                );
    }

    if (type_ == DisplayFilterToApply) {
        clear_button_ = new StockIconToolButton(this, "x-filter-clear");
        clear_button_->setCursor(Qt::ArrowCursor);
        clear_button_->setToolTip(QString());
        clear_button_->setIconSize(QSize(14, 14));
        clear_button_->setStyleSheet(
                "QToolButton {"
                "  border: none;"
                "  background: transparent;" // Disables platform style on Windows.
                "  padding: 0 0 0 0;"
                "  margin-left: 1px;"
                "}"
                );
        connect(clear_button_, SIGNAL(clicked()), this, SLOT(clearFilter()));
    }

    connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(checkFilter(const QString&)));

    if (type_ == DisplayFilterToApply) {
        apply_button_ = new StockIconToolButton(this, "x-filter-apply");
        apply_button_->setCursor(Qt::ArrowCursor);
        apply_button_->setEnabled(false);
        apply_button_->setToolTip(tr("Apply this filter string to the display."));
        apply_button_->setIconSize(QSize(24, 14));
        apply_button_->setStyleSheet(
                "QToolButton {"
                "  border: none;"
                "  background: transparent;" // Disables platform style on Windows.
                "  padding: 0 0 0 0;"
                "}"
                );
        connect(apply_button_, SIGNAL(clicked()), this, SLOT(applyDisplayFilter()));
        connect(this, SIGNAL(returnPressed()), this, SLOT(applyDisplayFilter()));
    }

    int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
    QSize bksz;
    if (bookmark_button_) {
        bksz = bookmark_button_->sizeHint();
    }
    QSize cbsz;
    if (clear_button_) {
        cbsz = clear_button_->sizeHint();
    }
    QSize apsz;
    if (apply_button_) {
        apsz = apply_button_->sizeHint();
    }
    setStyleSheet(QString(
            "DisplayFilterEdit {"
            "  padding-left: %1px;"
            "  margin-left: %2px;"
            "  margin-right: %3px;"
            "}"
            )
            .arg(frameWidth + 1)
            .arg(bksz.width())
            .arg(cbsz.width() + apsz.width() + frameWidth + 1)
                  );
    checkFilter();
}