Example #1
0
KGetLinkView::KGetLinkView(QWidget *parent)
    : KDialog(parent), m_linkImporter(0)
{
    setCaption(i18n("Import Links"));

    // proxy model to filter links
    m_proxyModel = new KGetSortFilterProxyModel();
    m_proxyModel->setDynamicSortFilter(true);
    m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);

    QWidget *widget = new QWidget(this);
    ui.setupUi(widget);

    // set the Icons
    ui.importLinks->setIcon(KIcon("document-import"));
    ui.showAll->setIcon(KIcon("view-list-icons"));
    ui.showArchives->setIcon(KIcon("package-x-generic"));
    ui.showAudio->setIcon(KIcon("audio-x-generic"));
    ui.showImages->setIcon(KIcon("image-x-generic"));
    ui.showVideos->setIcon(KIcon("video-x-generic"));

    // set the ids for the filterButtonGroup
    ui.filterButtonGroup->setId(ui.showAll, KGetSortFilterProxyModel::NoFilter);
    ui.filterButtonGroup->setId(ui.showArchives, KGetSortFilterProxyModel::CompressedFiles);
    ui.filterButtonGroup->setId(ui.showAudio, KGetSortFilterProxyModel::AudioFiles);
    ui.filterButtonGroup->setId(ui.showImages, KGetSortFilterProxyModel::ImageFiles);
    ui.filterButtonGroup->setId(ui.showVideos, KGetSortFilterProxyModel::VideoFiles);

    ui.treeView->setModel(m_proxyModel);
    ui.progressBar->hide();

    connect(ui.treeView, SIGNAL(doubleClicked(const QModelIndex &)),
            this, SLOT(uncheckItem(const QModelIndex &)));
    connect(ui.textFilter, SIGNAL(textChanged(QString)), SLOT(setTextFilter(QString)));
    connect(ui.filterMode, SIGNAL(currentIndexChanged(int)), m_proxyModel, SLOT(setFilterMode(int)));
    connect(ui.filterButtonGroup, SIGNAL(buttonClicked(int)), m_proxyModel, SLOT(setFilterType(int)));
    connect(ui.filterButtonGroup, SIGNAL(buttonClicked(int)), SLOT(updateSelectionButtons()));
    connect(ui.urlRequester, SIGNAL(textChanged(const QString &)), SLOT(updateImportButtonStatus(const QString &)));
    connect(ui.selectAll, SIGNAL(clicked()), this, SLOT(checkAll()));
    connect(ui.deselectAll, SIGNAL(clicked()), this, SLOT(uncheckAll()));
    connect(ui.checkSelected, SIGNAL(clicked()), this, SLOT(slotCheckSelected()));
    connect(ui.invertSelection, SIGNAL(clicked()), this, SLOT(slotInvertSelection()));
    connect(this, SIGNAL(okClicked()), this, SLOT(slotStartLeech()));
    connect(ui.showWebContent, SIGNAL(stateChanged(int)), m_proxyModel, SLOT(setShowWebContent(int)));
    connect(ui.importLinks, SIGNAL(clicked()), this, SLOT(slotStartImport()));
    connect(ui.treeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
            SLOT(selectionChanged()));

    setMainWidget(widget);
    setButtonText(KDialog::Ok, i18nc("Download the items which have been selected","&Download Checked"));
    setButtonIcon(KDialog::Ok, KIcon("kget"));

    checkClipboard();
}
Example #2
0
bool VideoFilterDialog::Create()
{
    if (!LoadWindowFromXML("video-ui.xml", "filter", this))
        return false;

    bool err = false;
    UIUtilE::Assign(this, m_textfilter, "textfilter_input", &err);
    UIUtilE::Assign(this, m_yearList, "year_select", &err);
    UIUtilE::Assign(this, m_userratingList, "userrating_select", &err);
    UIUtilE::Assign(this, m_categoryList, "category_select", &err);
    UIUtilE::Assign(this, m_countryList, "country_select", &err);
    UIUtilE::Assign(this, m_genreList, "genre_select", &err);
    UIUtilE::Assign(this, m_castList, "cast_select", &err);
    UIUtilE::Assign(this, m_runtimeList, "runtime_select", &err);
    UIUtilE::Assign(this, m_browseList, "browse_select", &err);
    UIUtilE::Assign(this, m_watchedList, "watched_select", &err);
    UIUtilE::Assign(this, m_inetrefList, "inetref_select", &err);
    UIUtilE::Assign(this, m_coverfileList, "coverfile_select", &err);
    UIUtilE::Assign(this, m_orderbyList, "orderby_select", &err);

    UIUtilE::Assign(this, m_doneButton, "done_button", &err);
    UIUtilE::Assign(this, m_saveButton, "save_button", &err);

    UIUtilE::Assign(this, m_numvideosText, "numvideos_text", &err);

    if (err)
    {
        LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'filter'");
        return false;
    }

    BuildFocusList();

    fillWidgets();
    update_numvideo();

    connect(m_yearList, SIGNAL(itemSelected(MythUIButtonListItem*)),
            SLOT(SetYear(MythUIButtonListItem*)));
    connect(m_userratingList, SIGNAL(itemSelected(MythUIButtonListItem*)),
            SLOT(SetUserRating(MythUIButtonListItem*)));
    connect(m_categoryList, SIGNAL(itemSelected(MythUIButtonListItem*)),
            SLOT(SetCategory(MythUIButtonListItem*)));
    connect(m_countryList, SIGNAL(itemSelected(MythUIButtonListItem*)),
            SLOT(setCountry(MythUIButtonListItem*)));
    connect(m_genreList,SIGNAL(itemSelected(MythUIButtonListItem*)),
            SLOT(setGenre(MythUIButtonListItem*)));
    connect(m_castList,SIGNAL(itemSelected(MythUIButtonListItem*)),
            SLOT(SetCast(MythUIButtonListItem*)));
    connect(m_runtimeList, SIGNAL(itemSelected(MythUIButtonListItem*)),
            SLOT(setRunTime(MythUIButtonListItem*)));
    connect(m_browseList, SIGNAL(itemSelected(MythUIButtonListItem*)),
            SLOT(SetBrowse(MythUIButtonListItem*)));
    connect(m_watchedList, SIGNAL(itemSelected(MythUIButtonListItem*)),
            SLOT(SetWatched(MythUIButtonListItem*)));
    connect(m_inetrefList, SIGNAL(itemSelected(MythUIButtonListItem*)),
            SLOT(SetInetRef(MythUIButtonListItem*)));
    connect(m_coverfileList, SIGNAL(itemSelected(MythUIButtonListItem*)),
            SLOT(SetCoverFile(MythUIButtonListItem*)));
    connect(m_orderbyList, SIGNAL(itemSelected(MythUIButtonListItem*)),
            SLOT(setOrderby(MythUIButtonListItem*)));
    connect(m_textfilter, SIGNAL(valueChanged()),
            SLOT(setTextFilter()));

    connect(m_saveButton, SIGNAL(Clicked()), SLOT(saveAsDefault()));
    connect(m_doneButton, SIGNAL(Clicked()), SLOT(saveAndExit()));

    return true;
}
Example #3
0
bool MyMoneyReport::read ( const QDomElement& e )
{
  // The goal of this reading method is 100% backward AND 100% forward
  // compatability.  Any report ever created with any version of KMyMoney
  // should be able to be loaded by this method (as long as it's one of the
  // report types supported in this version, of course)

  bool result = false;

  if (
    "REPORT" == e.tagName()
    &&
    (
      ( e.attribute ( "type" ).find ( "pivottable 1." ) == 0 )
      ||
      ( e.attribute ( "type" ).find ( "querytable 1." ) == 0 )
      ||
      ( e.attribute ( "type" ).find ( "infotable 1." ) == 0 )
    )
  )
  {
    result = true;
    clear();

    int i;
    m_name = e.attribute ( "name" );
    m_comment = e.attribute ( "comment", "Extremely old report" );

    //set report type
    if(!e.attribute ( "type" ).find ( "pivottable" )) {
      m_reportType = MyMoneyReport::ePivotTable;
    } else if(!e.attribute ( "type" ).find ( "querytable" )) {
      m_reportType = MyMoneyReport::eQueryTable;
    } else if(!e.attribute ( "type" ).find ( "infotable" )) {
      m_reportType = MyMoneyReport::eInfoTable;
    } else {
      m_reportType = MyMoneyReport::eNoReport;
    }

    // Removed the line that screened out loading reports that are called
    // "Default Report".  It's possible for the user to change the comment
    // to this, and we'd hate for it to break as a result.
    m_group = e.attribute ( "group" );
    m_id = e.attribute ( "id" );

    //check for reports with older settings which didn't have the detail attribute
    if ( e.hasAttribute ( "detail" ) )
    {
      i = kDetailLevelText.findIndex ( e.attribute ( "detail", "all" ) );
      if ( i != -1 )
        m_detailLevel = static_cast<EDetailLevel> ( i );
    } else if ( e.attribute ( "showsubaccounts", "0" ).toUInt() ) {
      //set to show all accounts
      m_detailLevel = eDetailAll;
    } else {
      //set to show the top level account instead
      m_detailLevel = eDetailTop;
    }

    m_convertCurrency = e.attribute ( "convertcurrency", "1" ).toUInt();
    m_favorite = e.attribute ( "favorite", "0" ).toUInt();
    m_tax = e.attribute ( "tax", "0" ).toUInt();
    m_investments = e.attribute ( "investments", "0" ).toUInt();
    m_loans = e.attribute ( "loans", "0" ).toUInt();
    m_includeSchedules = e.attribute ( "includeschedules", "0" ).toUInt();
    m_columnsAreDays = e.attribute ( "columnsaredays", "0" ).toUInt();
    m_includeTransfers = e.attribute ( "includestransfers", "0" ).toUInt();
    if ( e.hasAttribute ( "budget" ) )
      m_budgetId = e.attribute ( "budget" );
    m_includeBudgetActuals = e.attribute ( "includesactuals", "0" ).toUInt();
    m_includeUnusedAccounts = e.attribute ( "includeunused", "0" ).toUInt();
    m_includeForecast = e.attribute ( "includesforecast", "0" ).toUInt();
    m_includePrice = e.attribute ( "includesprice", "0" ).toUInt();
    m_includeAveragePrice = e.attribute ( "includesaverageprice", "0" ).toUInt();
    m_includeMovingAverage = e.attribute ( "includesmovingaverage", "0" ).toUInt();
    if( m_includeMovingAverage )
      m_movingAverageDays = e.attribute ( "movingaveragedays", "1" ).toUInt();

    //only load chart data if it is a pivot table
    if ( m_reportType == ePivotTable ) {
      i = kChartTypeText.findIndex ( e.attribute ( "charttype" ) );

      if ( i != -1 )
        m_chartType = static_cast<EChartType> ( i );

      //if it is invalid, set to first type
      if (m_chartType == eChartEnd)
        m_chartType = eChartLine;

      m_chartDataLabels = e.attribute ( "chartdatalabels", "1" ).toUInt();
      m_chartGridLines = e.attribute ( "chartgridlines", "1" ).toUInt();
      m_chartByDefault = e.attribute ( "chartbydefault", "0" ).toUInt();
      m_chartLineWidth = e.attribute ( "chartlinewidth", "2" ).toUInt();
    } else {
      m_chartType = static_cast<EChartType> ( 0 );
      m_chartDataLabels = true;
      m_chartGridLines = true;
      m_chartByDefault = false;
      m_chartLineWidth = 1;
    }

    QString datelockstr = e.attribute ( "datelock", "userdefined" );
    // Handle the pivot 1.2/query 1.1 case where the values were saved as
    // numbers
    bool ok = false;
    i = datelockstr.toUInt ( &ok );
    if ( !ok )
    {
      i = kDateLockText.findIndex ( datelockstr );
      if ( i == -1 )
        i = userDefined;
    }
    setDateFilter ( static_cast<dateOptionE> ( i ) );

    i = kRowTypeText.findIndex ( e.attribute ( "rowtype", "expenseincome" ) );
    if ( i != -1 )
    {
      setRowType ( static_cast<ERowType> ( i ) );
      // recent versions of KMyMoney always showed a total column for
      // income/expense reports. We turn it on for backward compatability
      // here. If the total column is turned off, the flag will be reset
      // in the next step
      if ( i == eExpenseIncome )
        m_showRowTotals = true;
    }
    if ( e.hasAttribute ( "showrowtotals" ) )
      m_showRowTotals = e.attribute ( "showrowtotals" ).toUInt();

    i = kColumnTypeText.findIndex ( e.attribute ( "columntype", "months" ) );
    if ( i != -1 )
      setColumnType ( static_cast<EColumnType> ( i ) );

    unsigned qc = 0;
    QStringList columns = QStringList::split ( ",", e.attribute ( "querycolumns", "none" ) );
    QStringList::const_iterator it_column = columns.begin();
    while ( it_column != columns.end() )
    {
      i = kQueryColumnsText.findIndex ( *it_column );
      if ( i > 0 )
        qc |= ( 1 << ( i - 1 ) );

      ++it_column;
    }
    setQueryColumns ( static_cast<EQueryColumns> ( qc ) );

    QDomNode child = e.firstChild();
    while ( !child.isNull() && child.isElement() )
    {
      QDomElement c = child.toElement();
      if ( "TEXT" == c.tagName() && c.hasAttribute ( "pattern" ) )
      {
        setTextFilter ( QRegExp ( c.attribute ( "pattern" ), c.attribute ( "casesensitive", "1" ).toUInt(), !c.attribute ( "regex", "1" ).toUInt() ), c.attribute ( "inverttext", "0" ).toUInt() );
      }
      if ( "TYPE" == c.tagName() && c.hasAttribute ( "type" ) )
      {
        i = kTypeText.findIndex ( c.attribute ( "type" ) );
        if ( i != -1 )
          addType ( i );
      }
      if ( "STATE" == c.tagName() && c.hasAttribute ( "state" ) )
      {
        i = kStateText.findIndex ( c.attribute ( "state" ) );
        if ( i != -1 )
          addState ( i );
      }
      if ( "NUMBER" == c.tagName() )
      {
        setNumberFilter ( c.attribute ( "from" ), c.attribute ( "to" ) );
      }
      if ( "AMOUNT" == c.tagName() )
      {
        setAmountFilter ( MyMoneyMoney ( c.attribute ( "from", "0/100" ) ), MyMoneyMoney ( c.attribute ( "to", "0/100" ) ) );
      }
      if ( "DATES" == c.tagName() )
      {
        QDate from, to;
        if ( c.hasAttribute ( "from" ) )
          from = QDate::fromString ( c.attribute ( "from" ), Qt::ISODate );
        if ( c.hasAttribute ( "to" ) )
          to = QDate::fromString ( c.attribute ( "to" ), Qt::ISODate );
        MyMoneyTransactionFilter::setDateFilter ( from, to );
      }
      if ( "PAYEE" == c.tagName() )
      {
        addPayee ( c.attribute ( "id" ) );
      }
      if ( "CATEGORY" == c.tagName() && c.hasAttribute ( "id" ) )
      {
        addCategory ( c.attribute ( "id" ) );
      }
      if ( "ACCOUNT" == c.tagName() && c.hasAttribute ( "id" ) )
      {
        addAccount ( c.attribute ( "id" ) );
      }
      if ( "ACCOUNTGROUP" == c.tagName() && c.hasAttribute ( "group" ) )
      {
        i = kAccountTypeText.findIndex ( c.attribute ( "group" ) );
        if ( i != -1 )
          addAccountGroup ( static_cast<MyMoneyAccount::accountTypeE> ( i ) );
      }
      child = child.nextSibling();
    }
  }
  return result;
}