From 5ebfa5253cc5d3d6a5e093bf9a02238e98968ecd Mon Sep 17 00:00:00 2001 From: Vedran Ljubovic Date: Thu, 23 Aug 2007 11:09:05 +0000 Subject: [PATCH] FileView::update_path() will now also update the displayed filename - this will simplify FileIconView implementation --- efiler/EDE_FileDetailsView.cpp | 20 ++++++++++++++++---- efiler/EDE_FileView.h | 5 ----- efiler/fileops.cpp | 11 +++-------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/efiler/EDE_FileDetailsView.cpp b/efiler/EDE_FileDetailsView.cpp index a7a50b4..cc6ec1f 100644 --- a/efiler/EDE_FileDetailsView.cpp +++ b/efiler/EDE_FileDetailsView.cpp @@ -16,6 +16,7 @@ #include #include #include +#include // used in update_path() #include #include @@ -175,9 +176,11 @@ FileDetailsView::FileDetailsView(int X, int Y, int W, int H, char*label) : EDE_B // struct FileItem (defined in EDE_FileView.h) void FileDetailsView::insert(int row, FileItem *item) { + // edelib::String doesn't support adding plain char + char cc[2]; cc[0]=column_char(); cc[1]='\0'; + // Construct browser line - edelib::String value; - value = item->name+"\t"+item->description+"\t"+item->size+"\t"+item->date+"\t"+item->permissions; + edelib::String value = item->name + cc + item->description + cc + item->size + cc + item->date + cc + item->permissions; char* realpath = strdup(item->realpath.c_str()); EDE_Browser::insert(row, value.c_str(), realpath); // put realpath into data bucket.add(realpath); @@ -200,8 +203,11 @@ void FileDetailsView::update(FileItem *item) { // c) causes browser to lose focus, making it impossible to click on something while // directory is loading - edelib::String value; - value = item->name+"\t"+item->description+"\t"+item->size+"\t"+item->date+"\t"+item->permissions; + // edelib::String doesn't support adding plain char + char cc[2]; cc[0]=column_char(); cc[1]='\0'; + + // Construct browser line + edelib::String value = item->name + cc + item->description + cc + item->size + cc + item->date + cc + item->permissions; char* realpath = strdup(item->realpath.c_str()); text(row, value.c_str()); data(row, realpath); @@ -221,6 +227,12 @@ void FileDetailsView::update_path(const char* oldpath,const char* newpath) { char* c = strdup(newpath); data(row,c); bucket.add(c); + + // Update filename in list + char* oldline = strchr(text(row), column_char()); + edelib::String line = fl_filename_name(newpath); + line += oldline; + text(row, line.c_str()); } diff --git a/efiler/EDE_FileView.h b/efiler/EDE_FileView.h index ddde338..10acbd6 100644 --- a/efiler/EDE_FileView.h +++ b/efiler/EDE_FileView.h @@ -146,11 +146,6 @@ public: int get_focus() { if (m_type==FILE_DETAILS_VIEW) return browser->get_focus(); else return icons->get_focus(); } void set_focus(int i) { if (m_type==FILE_DETAILS_VIEW) browser->set_focus(i); else icons->set_focus(i);} int take_focus() { if (m_type==FILE_DETAILS_VIEW) return browser->take_focus(); else return icons->take_focus(); } - - // These methods are used by do_rename() - should become obsoleted - const char* text(int i) { return browser->text(i); } - void text(int i, const char* c) { return browser->text(i,c); } - uchar column_char() { return browser->column_char(); } }; diff --git a/efiler/fileops.cpp b/efiler/fileops.cpp index a62fbff..9aa8d07 100644 --- a/efiler/fileops.cpp +++ b/efiler/fileops.cpp @@ -355,15 +355,8 @@ void do_rename(const char* newname) { ede_alert(tsprintf(_("Filename already in use: %s"), newname)); else if (!edelib::file_rename(oldpath,newpath)) ede_alert(tsprintf(_("Rename %s to %s failed!"), oldname, newname)); - else { - // Insert new name into vline - // FIXME text() methods shouldn't be exported by view! - edelib::String vline = view->text(focus); - vline = newname + vline.substr(vline.find(view->column_char(),0)); - view->text(focus,vline.c_str()); - + else view->update_path(oldpath,newpath); - } } @@ -393,6 +386,7 @@ void do_paste(const char* t) { fprintf (stderr, "PASTE from '%s', to '%s', type=%d\n",(char*)Fl::event_text(),to,operation); + if (!strchr(Fl::event_text(), '/')) return; // User is pasting something that isn't files // TODO: create a text file? @@ -474,6 +468,7 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]); else c = ede_choice_alert(tsprintf(_("Copy or move these %d files to directory\n\t%s ?"), count, to), _("C&ancel"), _("&Copy"), _("&Move")); +fprintf(stderr, "Exited choice_alert\n"); if (c==0) goto FINISH; if (c==1) operation=COPY; else operation=CUT; }