Beispiel #1
0
int main( int argc, char* argv[] ){
	if(argc != 2){
		return std::cerr<<"No!"<<std::endl;
	}
    QApplication a(argc,argv);

    std::ifstream file;

    file.open(argv[1]);
    std::string line;
    std::string alltext;
    while(getline(file, line)){
    	alltext += line;
       	alltext += "\n";
    }
    file.close();
    QString filetext(QString::fromStdString(alltext));

	DnDAddressModel model(filetext);

	QListView listView;
	listView.setModel(&model);
	listView.setModelColumn(0);
	listView.show();

	QTreeView treeView;
	treeView.setModel(&model);
	treeView.show();

	QTableView tableView;
	tableView.setModel(&model);
	tableView.show();

	return a.exec();
}
Beispiel #2
0
void RSA::decryptRSA (char* fileText,char* fileKey,char *fileDecrypt)
{
    ifstream filetext(fileText);
    ofstream decrypt(fileDecrypt);
    ifstream PK(fileKey);
     if(!PK){
        cout<<"Fail!publicKey.txt isn't exist";
        return;
    }
    if(!filetext){
        cout<<"Fail!filetext.txt isn't exist";
        return;
    }
    ZZZ n,d,code;
    string a;
    /*read key from fileKey*/
    PK>>a; n=a;
    PK>>a; d=a;
    /*read text from fileText*/
    filetext>>a;
    /*decrypto base64 to bits*/
    code.set_str(de_convert_base64(a),2);
    /*M=C^d mode n*/
    mpz_powm(code.get_mpz_t(),code.get_mpz_t(),d.get_mpz_t(),n.get_mpz_t());
    /*convert to bit and crop length of KEY{128,192,256}*/
    a=code.get_str(2);
    a=a.substr(2048-KEY,KEY);
    /********************/
    code.set_str(a,2);
    decrypt<<code.get_str();

    filetext.close();
    decrypt.close();
    PK.close();
}
Beispiel #3
0
void RSA::cryptRSA (char* fileMText,char* fileKey,char *fileCrypt)
{
    string headCode="1000010010000100";/*head16bit*/
    ifstream filetext(fileMText);
    ifstream filekey(fileKey);
    ofstream filecrypt(fileCrypt);
    if(!filetext){
        cout<<"Fail!Filetext isn't exist";
        return;
    }
    if(!filekey){
        cout<<"Fail!Filekey isn't exist";
        return;
    }
    /*read key from fileKey*/
    string TEXT;
    ZZZ n,e;
    filekey>>TEXT;
    n=TEXT;
    filekey>>TEXT;
    e=TEXT;
    /*linked head16bit with bit random + KEY{128,192,256}*/
    TEXT=headCode;
    ZZ numbersite;
    RandomBits(numbersite,(2032-KEY));
    stringstream buffer;
    buffer<<numbersite;
    ZZZ code;
    code=buffer.str();
    int strlen=code.get_str(2).length();
    for(;strlen<2032-KEY;strlen++)TEXT+='1';
    TEXT+=code.get_str(2);
    filetext>>headCode;
    code=headCode;
    TEXT+=code.get_str(2);
    /*********************/
    /*C=M^e mod n*/
    code.set_str(TEXT,2);
    mpz_powm(code.get_mpz_t(),code.get_mpz_t(),e.get_mpz_t(),n.get_mpz_t());
    filecrypt<<convert_base64(code.get_str(2))<<endl;

    filecrypt.close();
    filetext.close();
    filekey.close();
}
Beispiel #4
0
int main(int argc, char *argv[]) {
    if(argc != 2) {
        return std::cerr<<"No!"<<std::endl;
    }
    QApplication a(argc,argv);

    std::ifstream file;

    file.open(argv[1]);
    std::string line;
    std::string alltext;
    while(getline(file, line)) {
        alltext += line;
        alltext += "\n";
    }
    file.close();
    QString filetext(QString::fromStdString(alltext));
    CheckableAddressBookModel g(filetext);
    FilteringView h(&g);
    h.show();
    return a.exec();
}
Beispiel #5
0
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    this->readSettings();

    //设置标签字体颜色、居中
    QPalette paletteWhite;
    paletteWhite.setColor(QPalette::WindowText, Qt::white);
    ui->modelLabel->setPalette(paletteWhite);
    ui->tipLabel->setPalette(paletteWhite);
    QPalette paletteGray;
    paletteGray.setColor(QPalette::WindowText, Qt::gray);
    ui->timeLabel->setPalette(paletteGray);
    ui->nextLabel->setPalette(paletteGray);
    ui->modelLabel->setAlignment(Qt::AlignCenter);
    ui->timeLabel->setAlignment(Qt::AlignRight);
    ui->nextLabel->setAlignment(Qt::AlignLeft);
    ui->tipLabel->setAlignment(Qt::AlignRight);
    //

    QFile file(":/stylesheet.qss");
    file.open(QFile::ReadOnly);
    QTextStream filetext(&file);
    QString stylesheet = filetext.readAll();

    this->setAttribute(Qt::WA_TranslucentBackground, true);
    this->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
    this->setWindowOpacity(0.8); //半透明
    this->setStyleSheet(stylesheet); //载入StyleSheet

    //状态栏设置
    tary = new QSystemTrayIcon(this);
    tary->setIcon(QIcon(":/bahrsi.png"));
    aboutAction = new QAction(tr("About BahRSI"), this);
    quitAction = new QAction(tr("Quit BahRSI"), this);
    connect(this->aboutAction, SIGNAL(triggered()), this, SLOT(aboutBahRSI()));
    connect(this->quitAction, SIGNAL(triggered()), this, SLOT(quitBahRSI()));
    menu = new QMenu;
    menu->addAction(this->aboutAction);
    menu->addSeparator();
    menu->addAction(this->quitAction);
    tary->setContextMenu(menu);
    tary->show();
    //

    ui->progressBar->setTextVisible(false);
    ui->pushButton->setVisible(false);
    ui->pushButton->setText(tr("Postpone"));
    connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(postPone()));

    secondTimer = new QTimer(this);
    connect(this->secondTimer, SIGNAL(timeout()), this, SLOT(updateUI()));

    misecondTimer = new QTimer(this);
    connect(this->misecondTimer, SIGNAL(timeout()), this, SLOT(stepOne()));

    microPauseWorkTimer = new QTimer(this);
    connect(this->microPauseWorkTimer, SIGNAL(timeout()), this, SLOT(microPauseRest()));
    this->microPauseWorkTimer->start(microPauseWorkTime*1000);

    microPauseRestTimer = new QTimer(this);
    connect(this->microPauseRestTimer, SIGNAL(timeout()), this, SLOT(microPauseWork()));
    this->setMouseTracking(true);

    workBreakWorkTimer = new QTimer(this);
    connect(this->workBreakWorkTimer, SIGNAL(timeout()), this, SLOT(workBreakRest()));
    this->workBreakWorkTimer->start(workBreakWorkTime*1000*60);

    workBreakRestTimer = new QTimer(this);
    connect(this->workBreakRestTimer, SIGNAL(timeout()), this, SLOT(workBreakWork()));

}
operator_Dialog::operator_Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::operator_Dialog)
{
    ui->setupUi(this);

    QFile file(":/qstylesheet.qss");
        if(file.open(QFile::ReadOnly))
        {
            QTextStream filetext(&file);
            QString stylesheet = filetext.readAll();
            //ui->close_pushButton->setStyleSheet(stylesheet);
            ui->done_pushButton->setStyleSheet(stylesheet);
            ui->query_pushButton->setStyleSheet(stylesheet);

        }

        ui->tableWidget->setFrameShape(QFrame::NoFrame); //设置无边框

        ui->tableWidget->horizontalHeader()->setClickable(false); //设置表头不可点击(默认点击后进行排序)

        //设置表头字体加粗
        QFont font = this->font();
        font.setBold(true);
        ui->tableWidget->horizontalHeader()->setFont(font);

        ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); //设置不可编辑

        ui->tableWidget->horizontalHeader()->setStretchLastSection(true); //设置充满表宽度

        ui->tableWidget->setShowGrid(false); //设置不显示格子线

        ui->tableWidget->verticalHeader()->setVisible(false); //设置垂直头不可见

        ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);  //设置选择行为时每次选择一行

        ui->tableWidget->setStyleSheet("selection-background-color:lightblue;"); //设置选中背景色

        ui->tableWidget->setStyleSheet("background-color:rgba(0,0,0,80)");

        ui->tableWidget->horizontalHeader()->setStyleSheet("QHeaderView::section{background:skyblue;}"); //设置表头背景色

        //设置水平、垂直滚动条样式
        ui->tableWidget->horizontalScrollBar()->setStyleSheet("QScrollBar{background:transparent; height:15px;}"
          "QScrollBar::handle{background:black; border:2px solid transparent; border-radius:5px;}"
          "QScrollBar::handle:hover{background:solid gray;}"
          "QScrollBar::sub-line{background:transparent;}"
          "QScrollBar::add-line{background:transparent;}");

        ui->tableWidget->verticalScrollBar()->setStyleSheet("QScrollBar{background:transparent; width: 15px;}"
          "QScrollBar::handle{background:black; border:2px solid transparent; border-radius:5px;}"
          "QScrollBar::handle:hover{background:solid gray;}"
          "QScrollBar::sub-line{background:transparent;}"
          "QScrollBar::add-line{background:transparent;}");

        ui->yyyy_spinBox->setStyleSheet("QSpinBox{border:2px solid gray;}"
          "QSpinBox{background-color:solid white}"
          "QSpinBox::down-arrow{border-image:url(:/down4.png);}"
          "QSpinBox::up-arrow{border-image:url(:/up4.png);}");

        ui->mm_spinBox->setStyleSheet("QSpinBox{border:2px solid gray;}"
          "QSpinBox{background-color:solid white}"
          "QSpinBox::down-arrow{border-image:url(:/down4.png);}"
          "QSpinBox::up-arrow{border-image:url(:/up4.png);}");

        ui->dd_spinBox->setStyleSheet("QSpinBox{border:2px solid gray;}"
          "QSpinBox{background-color:solid white}"
          "QSpinBox::down-arrow{border-image:url(:/down4.png);}"
          "QSpinBox::up-arrow{border-image:url(:/up4.png);}");

        ui->label_remindMission->setStyleSheet("QLabel{font:bold;font-size:14px;color:black;background-color:rgba(0,0,0,0)}");
        ui->label->setStyleSheet("QLabel{font:bold;font-size:14px;color:black;background-color:rgba(0,0,0,0)}");
        ui->label_2->setStyleSheet("QLabel{font:bold;font-size:14px;color:black;background-color:rgba(0,0,0,0)}");
        ui->label_3->setStyleSheet("QLabel{font:bold;font-size:14px;color:black;background-color:rgba(0,0,0,0)}");


    model = new QSqlQueryModel();

    ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);

    ui->tableWidget->setColumnCount(8);

    QStringList header;
    header<<tr("ID")<<tr("name")<<tr("manufacturer")<<tr("approval_number")<<tr("value")<<tr("operate")<<tr("status")<<tr("date");
    ui->tableWidget->setHorizontalHeaderLabels(header);

    init_tableWidget();

    dateModelFlag = 0;


    ui->yyyy_spinBox->setValue(2014);         //设置初始值
    ui->yyyy_spinBox->setMinimum(2014);       //设置最小值
    ui->yyyy_spinBox->setRange(2014,3000);

    ui->mm_spinBox->setValue(1);
    ui->mm_spinBox->setRange(0,13);       //设置变化范围

    ui->dd_spinBox->setValue(1);
    ui->dd_spinBox->setRange(0,32);
    connect(ui->mm_spinBox, SIGNAL(valueChanged(int)), this, SLOT(mm_remind()));
    connect(ui->dd_spinBox, SIGNAL(valueChanged(int)), this, SLOT(dd_remind()));
    connect(ui->tableWidget,SIGNAL(itemClicked(QTableWidgetItem*)),this,SLOT(tableWidget_item_click()));
    connect(this, SIGNAL(refreshSignal(int)), this, SLOT(receiveRefreshSig(int)));
}